The first Congress passed a law in 1790 stating "And the children of citizens of the United States that may be born beyond sea, or outside the limits of the United States, shall be considered as natural born citizens" in Session II, Chapter 3.
Most military do not take their wives--particularly pregnant wives.
Most military do take their wives, except to the few locations that don't allow it. They are there for usually 3+ years, plenty of time to have kids. The Army hospital in Landstuhl, Germany, has a busy-enough maternity ward.
Then we have the United States Marines who’ve been guarding our embassies abroad for more than 2 centuries. No doubt there’s been more than ample opportunity for their children to be born in foreign countries. Not surprising that Congress took care of the question way back when.