https://www.pa.ng.mil/Community/Mailing-Deployed-Service-Members/
Basically their unit (or ship) gets assigned a special military PO box and the military takes care of it from there. USPS says you just pay like a domestic letter or package. It's almost certainly subsidized by the military. I assume the other package carriers are similar.