in TNG 'Tapestry', the alternate timeline Q allows Picard to see, where picard didn't take risks like picking a fight with naussicans, we see he went from ensign to only a Jr LT after 42 years of service in starfleet. in the words of Troi and Riker, Lt picard was "Your performance records have always been good. You're thorough… dedicated…"
"Steady, reliable… punctual." but he'd never progressed because "If you want to get ahead, you have to take chances… stand out in a crowd, get noticed!".
and just because Q was involved doesn't mean that the normal rules hot changed.. Picard himself, still having the mind of the 'real' picard, didn't find anything odd about the idea of a person staying at Jr LT rank for decades.
so clearly "up or out" does not apply to starfleet. you just tend to get ambitious people going for command track and the higher ranks.
honestly, it might be a concession to the longer lived species.. a vulcan might well have a career spanning a full century, and the federation seems to make strides to not discriminate based on species. so promotions being offered entirely on merit and performance instead of time in grade would fit. and we know that you can turn down promotions to a certain limit, from Riker and Rutherford's examples.