o Pelopponesian Wars, 433-403 BC. Athens v. Sparta. Sparta, the bad guys, win.
o Wars of empire, 233 BC - 9 AD. Rome v. Everybody. Rome, the bad guys, win, except at Teutobuerger Wald, where the Germans, the bad guys, win.
o Battle of Nis, Serbia, 387 AD. Rome v. the Goths. The Goths, the bad guys, win.
o Invasion of Anglo-Saxony, 1066. Normandy v. Saxon England. The Norman bastard, the bad guy, wins.
o Manzikert, Asia Minor, 1088. Byzantium v. the Turks. The Turks, the bad guys, win.
o Battle of Kosovo, 1389, Serbia v. the Turks. The Turks, the bad guys, win. (Whatever was made of this battle in later years, the Turks brought an era of terrible darkness to the Balkans when they took over Serbia.)
o Battle of Agincourt, 1415, English Empire v. the French. The English, the bad guys win (Shakespeare was a liar; Henry V was a thug and a war criminal).
o Fall of Constantinople, 1453, Byzantium v. the Turks. The Turks, the bad guys, win.
o Fall of Tenochtitlan, 1521. Spaniards v. the Aztecs. The Spaniards, the bad guys, win (although it's a REAL HARD CALL here, as the Aztecs were ALSO the bad guys).
o Fall of Incan Empire, 1532. Spaniards v. the Incans. The Spaniards, the bad guys, win again (but see above about the Aztecs; double ditto).
o Fall of Charles I; Cavaliers v. the Roundheads, 1649. The Roundheads, the bad guys, eventually win. (More specifically, The King, a bad guy, loses to Parliament, made up of slightly less bad guys, who then loses to the Roundheads, REAL bad guys, that is, religious bigots extraordinaire who execute the King and chase all the men of good sense out of government for eleven years as Cromwell rules by decree.)
I supposed I made my point. History is replete with bad guys who win. The Cowboy Code ain't entirely accurate.
Well......except in all of your examples, the US hadn't invented cowboys yet.