Further to Stuart F's comment:
The war college tradition of modern war games began with the von
Reisswitz's Kriegsspiel in the early 19th century. As it developed
through many variants over the course of the 19th century, the
Kriegsspiel established conventions of war gaming, such as identifying the opponents as red and blue, the use of maps and
umpires, and fundamental rules for movement and combat resolution.
H. Schramm et al.; Collection, Laboratory, Theater: (2005)
In 1811, Two young Prussian Princes, Fredrick and William, learnt of a
wargame invented by Herr von Reisswitz who was living in Berlin. They
were in [sic] intrigued by the idea and soon Reisswitz was given a
room in the palace to build a large plaster contoured model of
countryside at the arbitrary scale of 26 inches to the mile. The
troops were represented by wooden blocks with coloured paper stuck on
them. The games were regulated by a set of rules to decide the crucial
matters such as movement and firing. Withing a year, the king himself
started to play the wargame.
The development of the game was then led by Von Reisswitz's son, who
turned the rules for the game into something resembling a simulation
of war. The playing area model was replaced with more practical maps
at a scale of 8 inches to 1 mile. Dice were introduced to represent
the element of chance in war. The two sides were labelled as 'red'
and 'blue'; a naming convention that is still in wargaming.
In 1824, Reisswitz gave a lecture on the game to the general staff,
followed by a demonstration. The Prussian Chief of Staff, General
Muffling, received the game somewhat coldly at first, 'but as the
operations expanded on the map, and move by move the combatants worked
out their plans, the old general's face lit up, and at last he broke
out with enthusiasm: 'It's not a game at all, it's training for war. I
shall recommend it enthusiastically to the whole army'.
Professionally [sic] wargaming was then established.
John Curry; Verdy's Free Kriegspiel (2008)
As to why red and blue were chosen, they might be a carryover from Roman games.
Chariot racing was very popular in ancient Rome, where races were held
between teams (or factiones). The four Roman racing teams were known
by their colors—red, white, blue, and green. Red and blue teams
can be seen in this 19th-century illustration of a race at the Circus
Maximus. DK; Pocket Genius Horses: facts at Your Fingertips
Yet Roman chariot racing came as close as anything in the ancient
world to the team sports we know today. Each chariot belong to one of
four "factions" or colors, called Blue, Green, Red, and White.
Tombstones and other monuments for charioteers always indicated what
color they belonged to when they won their victories. Spectators were
loyal to their colors, and might identify themselves as Blues or
Greens depending on what team they rooted for. Anne Mahoney; Roman
Sports and Spectacles (2001)
Tertullian claims that there were originally just two factions, White
and Red, sacred to winter and summer respectively. By his time,
there were four factions; the Reds were dedicated to Mars, the
Whites to the Zephyrs, the Greens to Mother Earth or spring, and the Blues to the sky and sea or autumn. Each faction could
enter a team of up to three chariots per race. Members of the same
team often collaborated against the other teams, for example to force
them to crash into the spina (a legal and encouraged tactic).
The driver's clothing was color-coded in accordance with his faction, which would help distant spectators to keep track of the
race's progress. "Chariot Racing", Wikipedia