The switching of red and yellow from their TOS roles was already planned from the beginning.
The switch was because the TOS movies' use of wine red for all Starfleet officers' jackets, viewers had begun to associate wine with Admiral Kirk, Captain Spock and command.
Patrick Stewart tested better in wine (colour-shifted from TOS red) than mustard. It was also felt that using mustard for security diluted the old doomed "redshirt" jokes. The blue of science was colour-shifted to teal to avoid problems with bluescreen.
They did something similar during the TOS movies era. Section colours were less visible than in other time periods (just the turtleneck undershirts and epaulets instead of the various parts of the outer tunic), but they abandoned it later.
TMP increased from three (TOS) to six division colours:
White: command, Science: orange; Ship's Services/Helm: yellow; Engineering: red; Medical: mint green; Security: grey. The uniform colours were officers' personal choice of grey or beige.
ST II-VI, plus "Generations" prologue:
White: command, Science/Ship's Services: grey; Engineering/Helm: yellow; Medical: mint green; Security: black; Cadet: red. In the background, several other collar/cuff colours could be seen. The uniform jacket colour was wine.