The US didn't bomb Japan in retaliation for Pearl Harbor, but to accomplish a military objective. Also, past errors, to the extent there were any, are not valid reasons for current ones - otherwise we'd quickly have no laws or morality at all.
The Law of Armed Conflict (LOAC), which is taken very seriously by militaries, requires distinguishing between military and civilian people and assets, only pursuing military targets and objectives, and when civilians will be harmed, requires that it be in proportion to the military benefit.
Here are a couple of links. The first is the authoritative International Committee of the Red Cross's very usable LOAC page, and the second is the application of it to the Gaza war by leading experts:
https://ihl-databases.icrc.org/en/customary-ihl/v1
https://www.justsecurity.org/89489/expert-guidance-law-of-ar...