The business of being given the "Royal" title is a bit of a "black box", although each club needs to have a connection with the Royal family, and preferably a monarch. That does not mean that individual needed to be a member of the club but have a strong connection. There is much more that has gone on behind closed doors but that is a minimum requirement. Each Royal club will have a unique story to tell.
The question of why Prestwick is not Royal is part of a bigger story. Why aren't several clubs Royal, clubs such as the Honourable Company of Edinburgh Golfers (Muirfield), Swinley Forest, Wentworth and Sunningdale, for example. No one really knows, some clubs don't want the title, others have been excluded for "sins of the past".
The last club to be given the Royal title was Royal Mayfair in Edmonton (2005). Other recent Royals include Royal Regina (1999) and Royal Wellington (2004).
I can relate the story of how Royal Colwood became Royal. The then Prince of Wales, later King Edward VIII, later the Duke of Windsor after he abdicated, visited Victoria and played our course in 1919, 1923 and 1927. During the last visit our Secretary politely enquired if the Prince would favour us with his patronage, which he granted. Later a request was made to his father, King George V, to permit the use of the "Royal" title. With the Prince's support, permission was granted in 1931. There is a long story about mis communication between the Club, Rideau Hall (the residence of the Canadian Governor General, who is the monarch's representative in Canada), and Buckingham Palace. When King Edward VIII assumed the throne he reconfirmed the Royal title. Each club will have a similar story to tell.