Rebel that defense want work, after WWII they hung soldiers for that same excuse "I was only following orders"...
They are required to follow
LAWFUL orders. An order which is unlawful not only does not need to be obeyed, but obeying such an order can result in criminal prosecution of the one who obeys it. Military courts have long held that military members are accountable for their actions even while following orders -- if the order was illegal.
When you join the military you swear an oath to defend the Constitution from all enemies foreign and domestic, it comes before swearing to follow orders.....
Oath of officers
"I, _____ (SSAN), having been appointed an officer in the Army of the United States, as indicated above in the grade of _____ do solemnly swear (or affirm) that I will support and defend the Constitution of the United States against all enemies, foreign and domestic, that I will bear true faith and allegiance to the same; that I take this obligation freely, without any mental reservation or purpose of evasion; and that I will well and faithfully discharge the duties of the office upon which I am about to enter; So help me God." (DA Form 71, 1 August 1959, for officers.)
Oath of enlisted
I, (NAME), do solemnly swear (or affirm) that I will support and defend the Constitution of the United States against all enemies, foreign and domestic; that I will bear true faith and allegiance to the same; and that I 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. So help me God.