The oath of enlistment, sworn by everyone who joins the military, states they "will obey the orders of the President of the United States and the orders of the officers appointed over me, according to regulations and the Uniform Code of Military Justice."
The UCMJ contains several provisions and articles that stipulate that service men and women are liable for a wide variety of rules and regulations, regardless of whether they were ordered by a superior officer. That includes burglary, murder, assault, rape and property destruction.
UCMJ's Article 134 is a broad provision that prohibits "all disorders and neglects to the prejudice of good order and discipline in the armed forces, all conduct of a nature to bring discredit upon the armed forces, and crimes and offenses not capital," and is punishable in military court.
https://abcnews.go.com/Politics/military-oath-enlistment-legal-illegal-orders/story?id=127725085#:~:text=The%20oath%20of%20enlistment%2C%20sworn,private%20rights%20or%20personal%20affairs.%22