In the "early modern" period (pretty much 1600-1700) most armies operated by "commissioning" a Colonel to raise a regiment of foot or horse. The crown would give him a lump sum, he would use that to hire men, buy them weapons, armour, rations, and uniforms (and keep the "left-over" funds as his personal fee, so the incentive was to cut costs as much as possible).
Generally, soldiers would be issued a certain number of yards of cloth, which would be sewn into clothing by their female relative(s). The cheapest way to do it was to buy all the same kind of cloth wholesale, so there would be a "blue" regiment, a "grey" regiment, etc. Red was one of the cheapest dyes, so it was very popular in all armies.
The ideal was to have a soldier issued with enough cloth for a coat, pants, hat, and money for hose and shoes. In practice, they often received the bare minimum for a small coat.
100% standardized colours was almost never a thing until WW1, because different branches (Line Inf, Grenadiers, Skirmishers, Light Inf) would often have different coloured uniforms (skirmishers were usually green or black, for instance), but from the TYW/ECW onward uniforms gradually became more standardized by nation, as the "commission" method became more standardized/centralized/nationalized.
I think the "colonel buying cloth for his regiment" system began gradually to be phased out in most nations beginning at the turn of the 18th century.
Pic related, Gustavus Adolphus attempted to standardize uniform colours for his army and to go after corrupt colonels who abused their commission, but with limited success