Well, if you try to simply walk out of the place they can and will stop you at gunpoint, and can imprison you without resorting to the civilian justice system - the military can try, convict and punish you on their own according to their own regulations.