Curiously, in most Trek shows we only rarely establish that a Captain character is taking their first command in the context of their shows. For example, in assorted extended canons we understand that Kirk, while young, actually had multiple commands of other ships before taking the Enterprise. However in TOS itself, we’re given no indication whatsoever that the Enterprise was his first assignment as skipper, not counting any potential parallels with the JJverse. We also don’t know if Janeway, Archer, Sisko, Freeman, or I guess Pike or Georgiou definitely DIDN’T have a command assignment before taking command of their most famous assignments. It just hasn’t come up.
There’s one notable instance of a clearly unready captain getting a top ship, with Harriman getting the Enterprise-B. Again, novels have retconned this by establishing he got the ship through nepotism, though he ultimately became a competent commanding officer.
Then we have people like Riker, who was offered command multiple times and each time seems to have been a better ship: the light cruiser USS Drake; a ship to be sent on a long-range exploration mission in the USS Aries; the probably larger and more capable Excelsior/Nebula-class USS Melbourne; and finally the shiny new USS Titan. One could argue that the more important assignments came with Riker’s increasing experience and command ability, or it was simply that his name came up as next on the list of qualified officers.
In practice in the USN, commanding officers are generally assigned a vessel once they are deemed competent for command and will get whatever ship becomes available next; COs in the navy will of course rotate assignments regularly. There are general trends of matching background to assignment, for example an aircraft carrier’s CO is always a former naval aviator (and must have been XO of a carrier at some point, plus being a CO of another big ship), while all sub captains are themselves submariners and not surface boat sailors. This is in addition to special training not only as commanding officers but also in nuclear propulsion and the naval usage thereof, if you’re to command a nuclear-powered ship.
It would make sense that prospective Starfleet captains are assessed a command suited to their strengths and background, but other times some just seem to get a command assignment as a reward, as Picard may have when he got the Stargazer. For the most part though, if one is aiming for the captains chair, I’m fairly certain that they’d be trained to be happy to be even offered a command, and thus to accept whatever they got. Freeman may have been pining for a ship of the line, but it’s not like she seemed unhappy to have taken the Cerritos. This makes Riker the exception to the rule, but then we know Riker is exceptional in many ways.
Mark