The Federation should not have been surprised that their holograms developed sapience
We already know from TOS that Mutlitronic computers are able to develop sapience, with the M-5 computer being specifically designed to "think and reason" like a person, and built around Dr Daystrom's neural engrams.
However, we also know from Voyager that the holomatrix of their Mk 1 EMH also incorporates Multitronic technology, and from DS9 that it's also used in mind-reading devices.
Assuming that the EMH is designed to more or less be a standard hologram with some medical knowledge added in, it shouldn't have come as a surprise that holograms were either sapient themselves, or were capable of developing sapience. It would only be a logical possibility if technology that allowed human-like thought and reasoning into a hologram.
If anything, it is more of a surprise that sapient holograms like the Doctor or Moriarty hadn't happened earlier.
The cool thing about the Doctor's overall personal arc is that I think most fans would agree that probably he wasn't sentient in the early episodes, probably was by the end, and there's no clear moment when it changes (although I submit the events of "Latent Image" as a candidate).
Something I think we're all learning now with the rise of LLMs/Generative AI is that one can perform the act of intelligent self-awareness without consciousness or understanding. Sapience without sentience.