Someone who changes sides during a war is called a “turncoat”.
The term came from the actions of a former duke of Saxony who found himself and his land uncomfortably situated directly in the middle of a war between the French and the Saxons.
He quickly had a reversible coat made for himself, one side blue for the Saxons, and the other side white for the French.
Then, depending on who was occupying his land, he could wear the appropriate color of allegiance.
A traitor is still called a “turncoat” even today.