McCain wasn’t foreign-born. He was born in a US territory, same as Goldwater.
McCain was foreign born. As the State department says a base is not an embassy - it is not sovereign territory.
Furthermore the US never had sovereignty over the canal zone. It was a 99 year non renewable lease and never had congressional representation. Panama was never Puerto Rico - it was more like the Green zone of Bagdhad.
BTW, there is another US base overseas, built on land leased from a foreign government. It’s called Guantanamo. The last time I checked US law doesn’t extend there.