In what situation can I hold the ability key to use it asap after leaving the stun?

Does this apply to every skill?

Yes, but

There are a couple of skills that require a target. A few that come to mind are Mercy's Guardian Angel, Ana's Nano Boost, and Zenyatta's Orbs of Harmony/Discord. You need to have a target acquired when the skill becomes available or else it won't activate.

Does this work with every type of stun?

Yes.

Not only does it work with stuns and stun-like abilities, it works with the cooldown of the ability itself. If you really need to ice block but it's on cooldown, you can just hold the button for it and it will activate the instant it's ready.