I know this was a big deal in the Roman republic - by law no Roman army was permitted to enter the city. And I know part of the impetus behind the 2nd Amendment to the US Constitution was the perceived threat behind standing armies. But it seems like for modern democracies this isn't much of a concern - when and how did that perception change?
I think I might be able to offer a little insight into your question. There are various mechanisms in place in many modern militaries to prevent insurrection or revolution. For example, rotating officers to different places and commands keeps them from becoming to attached or influential (not really the best word choice) over their men. Similarly, having units that are made up of men from all over the nation, versus one town or state, helps defeat any attempts at organizing a revolt. Another part of this, less relevant today, is the illegality of plundering/sacking conquered places, which would give soldiers a means of income outside of the state and make them indebted to their commander on the promise of future spoils of war. I'm certainly not an expert, but that might help a little. I also would like to say that the perception of a standing army being a threat to the state and populace is very much still alive. As someone in the U.S where it is easy to take for granted our government's stability, its might be hard to imagine the military ever turning against the government or people. Also, this is a very real threat throughout the world in places with governments that aren't as stable as many Western countries. Finally, I would say that even in the U.S, there is a significant amount of people that very much distrust the government/military/police out of the very concerns you raised in your question.
The Nation. The invention of the Nation was a big part of it. Modern armies fight for their country, Roman armies were loyal to their generals first, Rome second.
Provisions. Ancient armies were mostly self-contained units. You had some guys with an assortment of pointy things that could march off to wherever and, as long as they were fed and not too homesick, continue fighting forever without any support from civilian leaders "back home" (which might not even mean much, as many Roman soldiers never set foot in Rome). Supply lines were a thing to consider, of course, but they often lived off the land for extended periods.
Modern armies, on the other hand, are highly, highly dependent on the industry of their nation. Ammunition, artillery, planes, body armor, Oreos, music, emails...a soldier at war is still part of, and dependent on, his society, often intimately. Without constant support from a huge industrial base, our fighting forces would be rendered useless in months, if not weeks.
Followup question: What part did centralized pay schemes play in this? Would distributed military pay (as opposed to direct pay from commanders and war booty) have diminished the threat a standing army had to a state's governance?