The GB would be coming from ISO 3166-1 which specifies it as the two-letter code for the United Kingdom. I don't know why UK isn't used there unless it's to avoid confusion with Ukraine (which is UA (the three letter codes for the United Kingdom and Ukraine are respectively GBR and UKR)).
I don't know the source for the suggested dialogue, unless it's simply using "UK" as the conventional abbreviation for the "UNITED KINGDOM" that would otherwise be correct (and of course is itself an abbreviation); Royal Mail guidelines would format the address as
Edinburgh Castle
Castlehill
EDINBURGH
EH1 2ND
UNITED KINGDOM
(How often does mail addressed to the United States end with "USA" compared with "UNITED STATES OF AMERICA"?)