Three colors is a perfect fit for the system of line vs. restricted line vs. staff. On the other hand, it's a piss-poor fit for a system of divisions, because Starfleet clearly has far more than three divisions, and uniform color never tells apart a useless cosmologist from a vitally important surgeon.
That implies that we know something about how the divisions are divided, but we don't. Three broad shipboard divisions of red (command, flight control, weapons), blue (science and medical) and gold (engineering, services and catch-all) seems to offer no more objections than line/staff/restricted. Indeed it may be a better fit: Data is qualified to command and slides right into being captain of a starship, why not just assume he's a line officer who happens to work in the gold division, rather than his status switching back and forth between restricted and unrestricted?