Laws have limits. War (and related activity) is doing what needs to be done when law is no longer helpful. Law is the result of some people bending others to their will.
...through consequence or threat of force, that is.
Exactly. War is by its very nature extra-legal. War is the state of affairs that exists when you are beyond rule-of-law; the purpose of war is to change circumstances such that a return to rule-of-law becomes possible.
While normal civilian law remains effective, you are not yet at war. When civilian law in unable to manage a conflict, or when your attackers are beyond its jurisdiction, or simply refuse to respect the limits of the rule of law, then you send a few stout men to kill them and anyone standing near them. For a period of time the gloves come off, and you do whatever you have to do to create a new status quo, so that you can return to rule of law.
What happens during this time that you are doing "whatever it takes" is dependent on your own moral character, the codes of military discipline, and the demands of the war itself. If you are winning, you can sometimes afford to be more restrained; if you are losing you will ramp up your response as the level of desperation rises.
If you can win with precision munitions that leave the building next door intact, great, but if we are scared enough we will use nukes and wipe out entire towns. That is reality. We can't afford to predict in advance what level of desperation we may find ourselves in, and we can't afford ever to treat war as a normal peacetime endeavor.
It isn't. We sometimes use the military in what is essentially a law enforcement role, but that isn't war. War is always a breach in the rule of law, and its purpose is to eliminate that breach by whatever means necessary.