In general, as
@Rod9301 said: quads, hamstrings, glutes are the usual culprits that are too weak, too tight, or imbalanced/some combination of the above.
Seeing a decent physiotherapist can be really useful. Sometimes it's that one muscle is working too hard and another is underperforming, and the combination of those means that your kneecap doesn't track properly (resulting in pain while skiing, stairs, etc). A combination of targeted strengthening of the underperforming muscles and stretching/foam rolling can be useful to get the right muscles working together again.
Last season I got a bunch of ski lessons in the hopes of making my ski technique more knee-friendly. My skiing improved, and my knee pain improved a lot.
I've been dealing with knee pain for over a decade now and it's a tricky beast, hope you sort yours out soon!!