Military personnel who are stationed abroad are subject to an inter governmental agreement called a Status of Forces Agreement which regulates all sorts of things concerning having armed people in the country. If it were not for the SOFA they could be regarded as being in possession of illegal weapons etc.
The admin, tax and discipline side of things are also covered, all in all you are better off with the advantages of the SOFA than you would be without it. Not that the soldier/sailor/airman has any choice in the matter.