First off, they generally don’t have guns. Unlike Israel, which conscripts their youth and makes them wander around their cities with rifles, the US military is quite keen on gun control.
Secondly, the US military has long been fascist, and has a well-refined system to encourage loyalty. They supply housing, healthcare, a higher discretionary income than average, with benefits that increase if you get married and have children. Once you’re out, you get funding for education, and preferential hiring, both from the government, and private employers via tax credits.
The US has slowly been building a warrior caste, which will only become more pronounced as the economic and social upheaval of the Industrial Revolution dissipates and feudalism reasserts itself.