It’s not law enforcement. It’s defense. Invade a foreign country and you are subject to the law of war, not civil and criminal law.
Not when the courts are open, Ex parte Milligan (1866).