In the US Military, a member of the armed forces, with few exceptions, is not tried by a US State or Federal Court. A court martial is a military tribunal set up to try a military member of a crime.
Any soldier who commits a military crime is court-martialled, i.e. tried by a military court.
Second Lieutenant William Calley was court martialled and convicted for the events at My Lai.
platoon leader Lt. William Calley
The Last Castle
Any soldier who commits a military crime is court-martialled, i.e. tried by a military court.
Three soldiers are court martialled in the Australian film 'Breaker Morant' (1980). Directed by Bruce Beresford, starring Edward Woodward and Bryan Brown, and set during the Boer War.
I think you are talking about the trenches in World War 1. You would be taken to the rear, Court-Martialled (tried) and executed (shot). To have lost your mind because of crushing bombardment was not a defence. Because Officers, who had not experienced this condition, did not recognize it as a medical condition, and called it "cowardice in the face of the enemy".
This is usually carried out by a "Military Tribunal", but may also be done by a senior officer, or in some cases, by a standard criminal or civil court. Many times it is simply called a "court martial", which means military court. This is where the term "court martial" comes from, as in "The soldier was court martialled,"
It makes no difference where he is, if the civilian law enforcement authorities notify the military that sufficient probable cause exists that he committed the crime, the military can take him into custody and ship him back to the US for trial. Depending on the seriousness of the offense the civil authorities might cede authority for his prosecution and punishment to the military justice system and he might be court martialled.
If you are not employed in the military, then you don't ever have to obey an order (unless you are on a military base or installation). If you are in the military, then any order given to you by a higher-ranked officer or NCO, or by your commanding officer, must be followed unless it violates the law. You can't ever decide to simply disobey an order just because of rank; doing so would get you court-martialled.
Technically, they were court-martialled and shot. 306 actually suffered this penalty in Britich and Commonwealth forces. Mostl, however, lesser punishments were applied. Most of the deserters shot have since been pardoned.
Deserters would be court martialled. The trial usually ended with them being sentenced to be shot at dawn by a 12 man firing squad. In WW2 the only offence for which you could be put to death was mutiny, whereas there were several more in WW1 including cowardice, and striking a superior officer.