But there are some cases in which treaties against performing certain actions can benefit both sides in a war (for example banning chemical weapons)
Both sides in most conflicts actually agree with these, which is why things like the Geneva Convention against certain weapons actually "work."
It is often noted that the Nazis (specifically IG Farben) invented, for instance, sarin nerve gas.
It is not from some squeamish morality, though, that the Nazis failed to use sarin and other nerve agents they had invented, against Allied personnel. They simply feared, pragmatically, that the use of such agents would provoke retaliation in kind and, indeed, the Allied powers had similarly awful nerve agents in store if it came to that.
It would not increase their chance of victory to use such agents.
As terrible as nerve agents are specifically, and chemical weapons in general are, they're very limited in utility for military uses. They're mainly area denial weapons. You can keep someone out of an area by deploying things that make an environment lethal. You also keep yourself out of the same area. Even with environmental protection suits and the like, most of these things are so lethal that even incidental contact results in nearly immediate death.
They're also good for massacring large amounts of civilians in a contained area of some kind.
This is why these kinds of agents have not been used, generally, for military purposes.
The main use of sarin in modern times was by an obscure Japanese cult, known as
Aum Shinrikyo, which used it for insane reasons when it launched a
nerve gas attack on the Tokyo subway system. These movie-villain-level maniacs also had produced a fair amount of VX, ebola, other shit like that, had even sought to buy stolen nuclear weapons in Russia, and murdered a lot of their critics, and been ignored and allowed to get away with this by buffoonish Japanese police.
In any event, part of why rules like the Geneva Convention actually "work" in terms of being agreed to by all sane parties to military conflicts, is that using nerve agents does not appreciably increase the chances of military success, but it vastly increases the penalties for losing.
Back to my original overbroad statement about the only real military ethics being winning. Because once you win, you decide what the ethics are.
As I've said before, the only difference between a "War hero" and a "War criminal" is which end of the bayonets your family is on.
I'm going to disagree with this, with two examples.
The Nazis specifically and the Axis in general are considered (rightly) two of the vilest powers ever to wage war.
However, the general opinion of Nazi general Erwin Rommel is that he was an honorable man.
Similarly, Admiral Yamamoto is widely admired for his personal integrity and skill.
(As everyone knows, Rommel was allowed to commit suicide after plotting to kill Hitler because Hitler feared the consequences of branding such a well regarded general a traitor, and of course, we assassinated Yamamoto to increase our chance of victory.)