"The first period when British military could have had much contact with Spanish women was during the Peninsular War."
The Black Prince led an expedition through Spain in the fourteenth century.
In the sixteenth, the King of Spain was also King of England as husband to Mary Tudor. Maybe (not) this song dates from 1558, when Elizabeth became queen, and the "We hope in a short time to see you again" line was a Catholic hope that Elizabeth would soon be deposed and England returned to the Catholic fold.
Or maybe (not) the song was written by someone in Prince Charles' entourage, as they returned from their failed attempt to win the hand of the Infanta.
British troops were campaigning in Catalonia in 1706.
And, given that the song has variants, it does not have to have a military or Royal Navy origin. There was 'always' trade with Spain, intermittently disrupted. Even the time of Elizabeth and Phillip II was not one of constant hostility.
Like the songs of Dibdin and all the rest, the song was quite likely the work of an armchair enthusiast whose closest link with Spain was a pint of sherry in a tavern in Deptford.
The idea that the pilots and masters used the song as a navigation aid, rather than charts and rutters and their own detailed knowledge - well, really?