Is there really 'that many' Starfleet officers though? There's 60,000 crew on the US's 11 aircraft carriers. The Nimitz classes are around 5,500 per. The new Ford class has more automation and is around 4,500. So far only the namesake Gerald R. Ford is active, although the John F Kennedy launches next year. The vast majority of the 'crew' are enlisted and not actually officers and gone through the Naval Academy though.
That's before getting into any other ships or bases. There's 65,000+ active officers in the Navy. The Naval Academy graduates around 1,000 new officers a year. There are other paths to becoming an officer though. So it may be Starfleet also has other paths, but they also probably need A LOT less.
Enterprise in SNW has I think 200+ crew. I would guess a portion did not go to Starfleet academy. Chief O'Brien went engineering school/program to Starfleet.