While Starfleet has naval ranks and traditions, and a defense role, it is incorrect to assume it operates in other ways like a 20th century military organization.
As Picard will tell you, "Starfleet is not a military organization, its purpose is exploration." And when scolding Wesley Crusher, "The first duty of every Starfleet officer is to the truth, whether it's scientific truth, or historical truth, or personal truth! It is the guiding principle on which Starfleet is based..." which doesn't sound like the first duty of a soldier, but that of a scientist, philosopher, and explorer.
Roddenberry envisioned Starfleet more like the US Coast Guard, an armed governmental organization which fills multiple roles. While technically military, they are not under the Department of Defense, and their purpose is not to make war. Defense is an auxiliary role. Instead, to paraphrase the Primary Duties of the US Coast Guard...
- assist in the enforcement of laws
- patrol to enforce those laws
- promote the safety of life and property
- develop and maintain aids to navigation
- engage in research
- function as a defense force in time of war
I think this sums up the line Starfleet straddles between being a military organization and an armed exploration, patrol, and police force.
Depictions of Starfleet have been more and less militaristic over the years. TOS was fairly militaristic, though very lax for the 1960s, with the apex probably being Wrath of Khan. TNG made the point to be explicitly not militaristic. DS9 showed in great detail the philosophical and organizational struggles Starfleet faced to avoid becoming a military organization while still being able to effectively defend the Federation.
On 20th and 21st century Earth, militaries would expand with war and contract with peace. This contraction left few opportunities for advancement and the ranks would become top heavy with old officers from the previous war. Once war loomed and expansion began, the ranks would swell and new officer positions would open resulting in young officers at high ranks.
For example, on Earth in the 20th century the United States started the Great War with a small army and expanded it to 4 million. The expansion and casualties offered many opportunities for young officers and even enlisted personnel to advance rapidly. With the end of the war it contracted greatly down to a few hundred thousand for two decades. Many officers left the service. Those who remained had to vie for the few positions available. The result was too many officers filling ranks they had too much experience for getting too old.
When the Second World War broke out that process repeated again: the US military rapid expanded, this time to 16 million people. The officers from the First World War and the time between formed and experienced core, but they were joined by a great number of young, fresh officers. And again, as casualties were inflicted more young officers rose through the ranks. General Mark Clark was the youngest 4-star general in the US Army at 48 years old.
After the war the cycle repeated itself, peace meant a contraction of the military and they found themselves once again top heavy.
But while Starfleet does expand to fight the Federation's wars, it does not undergo the severe wartime expansion and peacetime contraction of a 20th century Earth military. Fighting is not Starfleet's primary mission, exploration is, and there's always a constant need for ships to fulfill it. As a result Starfleet maintains a more steady size, steady casualty and retirement rate, and steady need for officers.
Furthermore, in 20th and 21st century Earth military organizations, promotion took on an almost fetish quality. Promotion was tied to power over lesser officers, increased respect, and better pay. Sometimes promotion was a pure seniority system with officers being rewarded with promotion for their years of experience, not for their talent. Rather than stay at a rank and position they were good at, officers could vie to be promoted beyond their capabilities leading to mediocre officers. And rather than promote the most talented officers, the eldest might be promoted instead.
While Starfleet has not completely eliminated this, it is significantly more egalitarian. With the decreased rigidity of rank, particularly in Picard's time, advancing in rank was less a pursuit of power and authority, and more a pursuit of excellence. Enlisted officers got similar quarters and benefits. Certainly in the Federation pay and was not an issue, and age discrimination was greatly reduced.
As a result, the simple 20th century Earth military idea that you advanced in rank with age by climbing over those below you cannot be assumed to be so in Starfleet. Starfleet had a more merit based system and ranks were less important than the job you did.
Instead, Starfleet acts more like a 21st century tech company where merit and role and getting the job done is more important than your official title. Except for everybody, not just white human males.
For example, take Chief O'Brien "the only enlisted man in Starfleet". He's not even an enlisted officer, but he chums around with the DS9 bridge crew. While Chiefs were certainly treated with great respect in 20th century navies for their technical knowledge and vital role in running a ship, they would not be treated as equals by the officers.
For another example of how rank was relatively less important in Starfleet, we regularly see officers of various ranks discussing a problem while on duty freely rather than going through a chain of command. They're respected for their talent and role on the ship, not for their rank. It's only in formal, heated, or disciplinary situations when Starfleet concerns itself about rank.
UPDATE: I can recall two canon instances explicitly about promotion in Starfleet in Picard's time: Riker and Barclay. While there are plenty of instances of someone being promoted, these are distinct as they show the Starfleet process and views around promotion beyond the Academy.
In The Best of Both Worlds Riker has turned down numerous offers for the captains chair, most recently the Melbourne. Both Picard and Admiral Hanson pressure him to reconsider, even though Will is quite content with where he's at. Commander Shelby represents a fresh rising star vying for his job. Riker, at just 31, is starting to feel "old" implying Starfleet officers, at least ones serving on the flagship, are young. Riker ultimately decides to stay where he's happy: as first officer of the Enterprise.
The second is Reg Barclay. In Hollow Pursuits he's a brilliant engineer, but still a Lieutenant Junior Grade. His anxieties have lead him into unprofessional holodeck fantasies. I recall concern that Barclay will remain a Lieutenant his entire career. The episode ends with Barclay solving a mystery that's making him look incompetent and making peace with his holodeck fantasies and anxieties.
In both cases, the concern is not so much with their career as it is whether they're living up to their talent and potential. With Riker it's whether he's afraid of "The Big Chair", and with Barclay it's his crippling anxiety. For Riker the answer was no, he's perfectly comfortable where he's at. For Barclay it's yes, his anxiety is holding him back. But neither are resolved with promotion.
Remaining at their ranks doesn't appear to have harmed either's career nor standing within Starfleet. Quite the contrary. We never hear about Riker's promotion offers again. Non-canon sources have him captaining the Titan, and the anti-time future shows him promoted to Admiral.
Barclay is promoted to full Lieutenant and remains there for, as far as we know, the rest of his career. He becomes a respected engineer at Jupiter Station, then returns to the Enterprise E, and finally is a key member of the Pathfinder Project to communicate with Voyager.