Germany uses a base in the western US for pilot training, that being Holloman AFB, New Mexico. We own the base, but they have a contingent permanently ‘settled’ on the flightline for just that purpose.
A lot of the bases that we have established in overseas countries are a result of new treaties (Al Jaber AB, Kuwait, Ali Al Salem, Kuwait, or Al Udeid, Qatar), historical reasons (Rammstein AB, Germany, or Balad AB, Iraq), or some other particular need (Thule AB, Greenland).
The answer to the OP has been pretty much answered in that a U.S. military presence in a nation or region tends to have a stabilizing effect on the political structure of the region, with ecenomic benefits to match. Go ahead, lob a few mortars at Al Udeid, and you’ll see how damn quick your mortarmen are turned into swiss cheese.
I’ve done the 'Deid.