We know very little about how Starfleet appoints it's captains.
Actually we know quite a bit because except for Kirk every command officer we've seen has been in his forties or fifties. That strongly suggests Starfleet tends to go with proven and tested officers.
How do you know that some of them didn't join the service as a second career? or maybe they were just really slow learners? or that they were political appointments?
Or maybe some of them were aliens who aged at a different rate and just had human sounding names.