Except McCain wasn’t born on the military base. The base had no medical facility for birthing so his mama had to deliver at the hospital (can’t think of the name off hand) in Colon.
His father was assigned to that US base. Wherever his US military father stepped on dirt or carpet, he was a US citizen and that dirt and carpet meant nothing and that goes for the wife, too. McCain was a US citizen the instant he was born. The US military has always had that rule when they send service men anywhere. Consider the US flag draped over every one of them wherever they are - they are an extension of the US.