The idea that a nation can legitimately claim territory just because it's nearby or because it wants to add to its land mass isn't one that we subscribe to in the modern world, nor is the idea that you can buy territory or just plant a flag and take a nation. Thankfully today we think in terms of self determination- the idea that the people should be the ones with the final say. At least most of the world does.
Woodrow Wilson brought about a fundamental change in thinking, from the days of empires and oppression to freedom and home rule. The principal of self determination he laid out is still considered to be right nearly a century on. This is what he said on the matter in 1918 after he announced his fourteen points:
The Falklands and Gibraltar are completely misunderstood by a lot of people. I know it's so easy to see somewhere like Gibraltar and shout 'colonialism', but that isn't quite the case. It is easier to understand if you look at what the situation would be if Britain was not involved. The example I think is most illustrative is that of Alaska in the USA.
Alaska was purchased by the USA from Tsarist Russia in 1867. This is in many ways similar to how Gibraltar was ceded to Britain in 1713 by the Spanish as a term in a treaty. At the time it was a normal occurrence- land changing hands like this was the established practice of the era. The people that actually lived in both weren't really either Spanish or Russian.