Dictated by the winners............If Japan had won the WWII, many in our military could have been tried for the fire bombing of everyone of their cities (our own Generals said as much).
That's true to an extent, less so now than even in WW2. But even our troops in WW2 were subjected to military courts for war crimes on a small percentage. It was kept confidential for decades but at least 400 U.S. troops received long prison sentences for rapes during WW2. So occasionally they would be prosecuted for their crimes. Although as a percentage 400 is well below what the actual number of rapes occurred, over a thousand were reported during the first ten days of occupation on one prefecture of Japan alone and in Okinawa it was commonplace for years. Of the 400 prosecuted, 126 were for rapes of Englishwomen in England so we cared more about raping our allies than the enemy although French women were definitely raped by us as well as the Germans.
And eventually the US took administrative steps if not criminal to stop our mass shootings of surrendering Japanese. From 1942 to the end of 1944 there was only one living Japanese POW for every 100 dead soldier, but in the beginning of 1945 while Japan was just starting up its suicide attacks meaning resistance was becoming more intense, administrative prosecution of our marines who shot surrendering troops meant that it jumped by Mid 1945 to one living Japanese POW for every 7 dead soldier. I doubt they were significantly more likely to surrender as we got to their home Islands if anything the opposite, we just shot them less while surrendering.
So yeah, winners do get prosecuted for war crimes far less, but good top level leaders can lessen them by controlling their own troops. Others like Patton didn't discourage it and probably encouraged it privately. After the Giscari Massacre during his Italian campaign where following a hotly contested fight over an airfield there were two separate incidents of US troops murdering POWs one which was the act of only one Sergeant who machine gunned down 36 in a holding pen and the other where a Captain of the 180th Infantry ordered his men to place another 35 in a line and then ordered an execution line where every man in his unit was ordered to choose a target and fire on command (which they did). When Patton learned about this in his journal he wrote,
"I told Bradley that it was probably an exaggeration, but in any case to tell the Officer to certify that the dead men were snipers or had attempted to escape or something, as it would make a stink in the press and also would make the civilians mad. Anyhow, they are dead, so nothing can be done about it."
So yeah...Patton ordered a coverup...shocking I know.
But, while you are correct in that winners frequently do not get prosecuted, my original point was that even in the worst of the worst where mankind truly hates one another there are rules and the worst offenders get taken care of.