That works when one side has an overwhelming power advantage, or when two sides are fighting a proxy war with little skin in the game. The dominant side(s) can afford to enforce rules that minimize its losses and the chance for escalation, and enforce those rules on the other party because, well, it's dominant. Basically all wars since WW2 have been fought on this template.
It goes out the window when there is actual uncertainty about who might win. Unrestricted submarine warfare was considered a war crime for most of peacetime, but as soon as it became a crucial strategic advantage that might turn the tide of the war, both sides started using it. The atom bomb would probably have been a war crime if it had been the losing side using it; as it is, it remains controversial.
Once one side wins the war, they become the dominant power again, and can enforce a definition of war crimes favorable to themselves. Such an event actually occurred with unrestricted submarine warfare: Admiral Nimitz testified for Karl Donitz at the latter's war crimes trial, because had unrestricted submarine warfare remained a war crime, the U.S. would have been guilty of it too.