Their engagements are planned months in advance, NewChapterBeckons. Planned surgery just means it’s not an emergency - it doesn’t mean it’s been in the diary for a couple of months. It would be planned surgery on Tuesday even if the surgeon decided on Monday it needs to be done urgently.
Whatever the operation, the need for it was clearly identified at some stage prior to yesterday, and when she was (presumably) admitted and the procedure took place. All of which was able to happen in privacy, without anyone knowing where she was.
This is not her first time being in a hospital under the glare of publicity, and I’m sure her past experiences have made her want to keep things like out of p[ublic knowledge as long as possible.