They were colorful so that troops could be identified on a smoky battlefield. The colors are also for morale purposes—pride in the unit.