Essentially the various Trek chains-of-command are “whatever will fit this story”, military tradition and sound personnel management practices be damned, and had the same internal consistency as everything else on the shows.
TNG kinda worked ad-hoc with the enlisted ranks, starting with the invisibility of TOS and eventually mentioning “crewmen 2d class” and stuff like that. In TOS you had the “everyone an officer” gimmick, yet there were Yeoman Rand and Chief Kyle… who wore uniforms indistinguishable from an “ensign”, as did those expendable red-shirts that would at times be addressed as “crewman” – as would the ocassional guy in a work smock. Apparently, anyone who wasn’t actually in the staff or line officer career track would just wear a plain uniform and so would the ensigns.
O’Brien did not get distinct CPO collar devices until DS9.
YPOD: In TOS, ensigns wore no emblem of rank, and there were no LTJG’s ever portrayed. Thus Kirk’s CAPT insignia during the TV run was, indeed, two-and-a-half braids. (in the pilot episode/s, it was even less detailed: the captain wore two braids, division officers wore one, everyone else was slick-sleeve) There was a mention once of a “fleet captain” but we never saw the braid for that. And there were only two flag ranks, commodore and “admiral” with no distinction of rear-, vice-, or fleet-. All that was to come later, with ST-2. Anyway, depending on the size/complexity of Starfleet – and remember, at the beginning of TOS it’s still not THAT huge an outfit, numerically – it could have started with a lean rank structure.
Which brings me to an observation I made: in Starfleet there seems to be no “up-or-out” policy (where you can’t just park yourself at a billet you like, if you’re not moving on to bigger, better things within X time you’re forced into mandatory early retirement or transfer to Reserves.) I can see how this would work in the TOS universe, where you had five-year deployments in out-of-the-way space. However in TNG, where it seems you’re back to Earth every 2 months and have higher-ups dropping in on you every Tuesday? TNG’s Riker declines promotion or command of his own or both, over and over and over and gets away with it. It does, however, explain in a way the expansion of rank titles from TOS to TNG: if you happen to be stuck for a whole decade on the same post (because someone up above in the ladder is welded to HIS chair) more frequent opportunities for rating or rank promotion, if you want it, are a way to keep up morale.