When you're using World War II-era technology and you are fighting the likes of the Empire of Japan and the Nazis, a regime so vicious that when they invaded the Soviet Union, the Soviet peoples initially welcomed them as liberators, only to then side with the Soviet government in the end because they were worse than Stalin's henchmen, you sometimes had no choice to do things like area bombing, because you had to knock out the enemy's ability to fight back. Had you not, they would have done their best to knock out your own ability to fight.
As said, the U.S. hasn't used area bombing in any recent war. For wars like Iraq, it wouldn't even make sense: "We the United States, are going to liberate you the Iraqi peoples from that brutal dictator Saddam Hussein, but in the process, we're probably going to kill a few hundred thousand of you bombing the smithereens out of the place." Not the best way to win affection with the people. Even with the Nazis, this was realized. Cities like Dresden were bombed because they were major manufacturing areas for German military production, but what was found was that although the bombs could destroy the buildings, the machinery often stayed intact. And the Germans were able to logistically divide up the process of manufacturing so that despite heavy bombing, German war production even increased. Which means that in hindsight, much of such bombing was pointless as it failed to achieve its goal (stopping German war production). It also had the nasty side effect of playing into the Nazis storyline to the German people that the Allies were no better than they (the Nazis were). One of the things that shut down the German military in the end was destroying the German oil refineries. Oil refining was too complex a process to divide up. In hindsight, had the Allies just focused on knocking out the oil production and not bombing any of the major German cities, they could have then portrayed themselves to the German peoples as not out to harm them at all, just to stop them from wreaking havoc the way they had.
Regarding the Hiroshima and Nagasaki bombings, that again was very controversial at the time. The Allies saw it that the only way to make the Japanese surrender was through brute force. But this meant either formally invading Japan, which it was estimated would've been the biggest slaughterfest of the war and one that they were not sure if the American people would even stand for (as the casualties would've been so high), or trying the atomic bombs on them. But it's not even certain that the atomic bombs in the end worked (or not necessarilly by themselves). They reluctantly decided on August 6, 1945, to drop one bomb, Little Boy, and the Japanese did not surrender. They then on August 9 dropped a second bomb, Fat Man, and still no surrender. On August 8, the Soviet Union declared war on Japan, and on August 9 (the same day Fat Man was dropped), began invading Japanese-occupied Manchuria. Meanwhile the U.S. considered dropping a third bomb. The Japanese then surrendered when the Emperor intervened, shocked by both of these events.