In the original Star Trek engineers and security officers wore red shirts but in ST:TNG engineers and security officers wore yellow shirts and command officers wore red shirts. Was it ever explained why there was a uniform color change?
In the pilot original series episodes (The Cage and The Man Trap), the science and security personnel wore blue; once the series went into production, engineering and security wore (as you said) red. (Enterprise also used this division colour scheme, but in a subtle line on the otherwise uniform uniforms).
In The Motion Picture, the security guards wore white uniforms with brown helmets and breastplates and engineers worse white spacesuits with black collars. In The Making of Star Trek: The Motion Picture, Roddenberry explained that the uniforms were redesigned because the original bright colours would distract viewers on the large screen. However, these changes proved unpopular, so were redesigned again for the later films.
BASHIR: Wait a minute, aren't you two wearing the wrong colour?
O'BRIEN: Don't you know anything about this period in time?
BASHIR: I'm a doctor, not an historian.
SISKO: In the old days, operations officers wore red, command officers wore gold.
DAX: And women wore less.
BASHIR: I think I'm going to like history.
Memory Alpha has a nice timeline of the colours for the different divisions.
As far as I know, an in-universe explanation for the change wasn't ever given (but the real military make changes like this too).
Out-of-universe, what I've read in various places suggests that it was due to colour-tests with the actors. In particular:
- Patrick Stewart and Jonathan Frakes looked better in red than in gold.
- Brent Spiner, in Data make-up, didn't look good in blue (i.e. blue on grey), and so his uniform was changed to the best combination with grey (gold). That led the way to making other changes.
The actual color schemes:
- Command (Operations): light Green - but it looks gold on screen due to lighting.
- Sciences/Medical: blue
- Engineering/Administration: red - but it looked pink on screen
- Command (Operations): Green - but it looks gold on screen
- Sciences/Medical: Blue
- Engineering/Support Services: Red - different fabric used, so it looks red.
worn only on the insignia, not the tunic colors
- Command: White
- Engineering: Red
- Helm: Yellow (same yellow as the film captured from the green tunics)
- Sciences: orange
- Medical: Surgical Green
- Security and Weapons: Gray
- Later TOS movies
Again, not on tunics
- Command: White
- Engineering/Helm/Gunnery: Yellow
- Science: Gray
- Medical: light green
- Security: dark green
- Special Services: Sky Blue
- Marines: Royal Blue
- Cadets: Red
- TNG flasbacks to movie style uniforms
Uniforms are red
- Command/Operations: White
- Engineering/Gunnery/Security: Yellow
- Sciences/Medical: gray
Note marines wear same 3 colors, but distinctive uniforms in DS9
- Command/Operations: Red
- Engineering/Security/Technical: Yellow
- Sciences/Medical: Blue
The gray used for sciences is a blue-gray.
So, the original "gold" becomes helm, then helm is merged into engineering, and engineering keeps it when helm merges back to command. This leaves red unused, but since red was the uniform primary color, making it the public face (namely, Command) makes sense.
Command starts out lime green (but films as gold)... then becomes white on gray then on red uniforms, then red on black uniforms.
Kirk's dress uniform was green to match his duty uniform, which looked gold under the studio lights.
I have books that were written during the production of seasons 1 and 2 of TOS, published after each wrapped. Don't know if there's a 3rd.
The 1st season shirts were what the costume department called "that damned velour" because it shrank when washed, not just the first washing but every washing. They had to be taken apart and re-fitted and sewn after every washing, eventually cut down for smaller actors.
It wasn't easy finding a gold fabric for the 2nd season that looked the same under the lights as the green velour.
Why not find a green fabric that didn't color shift under studio lights? Because it was already bought and there was a tight budget so they just went with what they had and to heck with the discontinuity of the green dress uniform.
ISTR there was a practical reason for science and medical both being blue and engineering and security both being red. Don't know if it was because Desilu couldn't afford more colors or if the velour wasn't available in more colors. Poorly exercised wetware wants to say there were two different shades of red but the color gamut of television made them look the same.
There's also a rarely seen uniform shirt in TOS that's a sort of kahki color with lots of pockets. I know it's worn by one person in a hallway scene in one episode.
The real answer is that a LOT of different people over VERY long periods of time either were handed color or costume or budget PROBLEMS that they dealt with the best that they could, or they weren't paying attention to things that would matter to fans A LOT. To be fair, they were lucky just to make the shows ( TOS, anyway ) at all. Expecting these costume departments ( and goofy executive producers ) to yield the same consistency that a real martial organization would is too much to hope for. Perhaps if paramount had gotten some World War II tailors of U.S. Army uniforms, a more consistent result could have been had.
In TOS the command color was CHARTRUESSE. There are 2 kinds of Chartruesse, one that is more green, and one that is yellow. Both have a kind of fluorescent quality. The original series used Chartruesse green. It was not studio lights that primarily caused them to appear gold, as reported elsewhere, that is wrong. The Technicolor film processing caused a color shift, and then the television NTSC systems at the time changed the color even more, so that by the time the image arrived in homes, audiences saw gold command shirts on Kirk, Chekov & Sulu.
The very first motion picture had a complete uniform update. I think they looked GREAT, but others panned them as looking like pajamas. All colors changed.
When Harve Bennett took over as producer of the motion pictures, he ordered the uniforms redesigned because he did not want "an all-gray crew on an all-gray ship". The same costume designer on the first movie was used for the next, Star Trek II: The Wrath Of Khan. Apparently he was given a lower budget. To save costs, some of the motion picture costume parts were reused. It turns out that the fabric took RED DYE better than any other, and so the red jackets became the standard for all starfleet crew.
If you look closely, some of the quilted-collar shirts that go under the red jackets have a different pastel hue. Departments are indicated by the color of the shoulder strap, arm band, and undershirt, although it was harder to tell them apart, and the audience couldn't really tell what color meant what.
All red-coat officer uniforms had a division colored stripe on the trousers or skirt that matches the shoulder strap and service bar, EXCEPT FOR COMMAND BRANCH, WHOSE STRIPES ARE RED, rather than white.
So after watching Captain Kirk in a red jacket for several movies & red striped trousers, red became the command color when STNG arrived. Supposedly, Frakes & Stewart looked better while wearing the color red, but I can't find a source for that.
Re-introducing colors meant engineering's old color was now reserved for command… so engineering & security got gold, and science-medical stayed blue. Why they did not bother adding 2 more colors, so that engineering & security could be separate, and medical & science could be split too, I do not know. Perhaps the 3-colors-only scheme of TOS was desired? Too much change for a TV property that was being re-introduced after being missing from television for ~30 years? Better to play it safe?
Then the DS9 uniforms had the color portion of the tunic moved to the shoulders, in order to have the actors framed by color instead of a zone of black. Also, making the body black hides actor's body problems when they put on weight or get pregnant or whatnot.