In the case of Custer, the Union Army at the start of the war numbered 16,367 officers and men comprising 198 line companies distributed among 4 artillery regiments, 5 mounted regiments, and 10 regiments of infantry. Out of that, a number went to the Confederate side. The Union Army quickly grew to over 2 million men. They pretty-much had no choice but to promote any regular officers they had to senior command.
At the start of WW-I, it was a similar deal, with a force of 90,000 being quickly expanded to over 4 million.
If what we're talking about in this new Star Trek universe is a situation where they just began a war with the Romulans where 95% the Fleet consists of people who had been raw civilians a few months prior, then yes they would have no choice except to use whatever regular officers that they had available. I guess I'll find the background when I go see it later this week.
In Pershings case, it was not quite as complicated. He was married to the daughter of an influentional Senator, that and exemplary service with the 10th Cav at San Juan Heights with a certain future president(Teddy) didn't hurt either.
Pershing tied the decorum of the army from Miles to the future Patton. Even in Mexico, Pershing shaved every day and wore a tie. He demanded the same from his officers.