"Lawful" as determined by the party executing the action is very different from actually lawful.
The courts can intervene later, but they can't un-bomb a hospital.
This is setting aside the obvious problem where governments will often set laws based on self-interest rather than morality, particularly when it comes to military conflict.