Except in the United States it is true. Something like 80% of new military recruits come from military families (parent, sibling, uncle/aunt, or grandparent).
Similarly over the last few decades the number of medical doctors who have immediate family who are also doctors has grown.
Social and economic class in the US is increasingly set in stone and hereditary.
I've noticed the same trend with SWEs tbh. Many new grads from the top schools have parents who were SWEs or SWE adjaent
Joining Military isn't really a "class" thing - unless you mean lower income people join the military more often to get started in life.
Military academies are more of a upper class thing though.
Medical schools require a lot of volunteering and things like 'slinging hot dogs to pay tuition' don't count unless you grew up without clothes surviving on rabid dogs in the holler of W Virginia working the coal mines from age 8. We all know who has time to volunteer or do minimum wage healthcare instead of work the best paying shitty side job they can get: the rich.
It's set up heavily tilted so you have to be rich, or dirt poor enough for a sob story, or a desired minority. Even if you do volunteer a lot and are middle class, you probably didnt know anyone that could help you into the most prestigious positions. A middle class person of equal aptitude would likely go into something like engineering or law which have fewer class-signalling non-academic purity tests.
I wonder how much of this has to do with seeing someone you are close to work as a doctor makes being a doctor (or military recruit, SWE, etc.) seem real and achievable to you. When I was little I wanted to be a firefighter purely because my father was a firefighter; it wouldn’t surprise me if the same goes for a lot of other people.