Japan bombed Pearl Harbor in retaliation for US's oil embargo. The Oil Embargo was due to Japan invading mainland Asia. Japan invaded mainland Asia due to... fascism. Imported from Germany.
But let's clear something up. Pearl Harbor was an attack on military assets, the bombings of Hiroshima and Nagasaki were war crimes meant to crush opposition.
US dropped the a-bomb on Japan to crush any remaining resistance from Japan, and as a threat to the wider world (namely the USSR). There was no prior warning given so no civilians were able to evacuate. Between 110,000‐210,000 civilians were murdered by the dropping of those two bombs.