“When the founders created the U.S. Constitution, they were very careful to insert roadblocks that would make it difficult for the government to use troops to carry out its own programs.”
A law professor who has written the book on domestic use of the military explains the laws: 

The Conversation
Trump orders Marines to Los Angeles as protests escalate over immigration raids, demonstrating the president’s power to deploy troops on US soil
American troops may be used inside the country, but it is an extraordinary exercise of authority to deploy them domestically, says an expert on the...