I have no idea why William pulled out of the event, but as a general thought / comment, I think I would be really struggling with my own mortality if I were him. The Queen's funeral must have brought home to him the sense that he'd moved one step closer to Charles' eventual death and subsequent funeral and then his own. A state funeral is such a spectacle, that it must be difficult to think about that happening to yourself one day.
Add in Charles' cancer diagnosis and suddenly everything must seem even more real. I think up until the Queen's death, becoming monarch must have seemed like something that was so far in the future it was almost an obscure kind of concept, but now it's so much closer and reality has set in.