The sunroofs are actuated (between the motor and the panel itself) by plastic coated steel cables that slide in grooves in the aluminum sunroof frame. By necessity, those grooves are open on the top, so the brackets that the sunroof panel is attached to can move back and forth.
So over time, dust and grit gets into those channels through normal use, and wear happens on the plastic coating, through sliding back and forth. And moisture gets the steel to rust, which expands and makes the cables stiffen up in the channels, and eventually seizes the roof in place when the motor can no long budge it.
If you can get it to budge and open, you can try cleaning/greasing those cables and getting them back into action with the sunroof still in the car. Try gently pushing down on the back edge of the roof as you try to open it, or try pushing gently up on the back as you try to get it in 'vent' position. Try going back and forth.
But if it's been stuck for a while, it's probably not going to free up doing that, and the alternative is taking the entire headliner out, and then removing the sunroof assembly and taking it apart to replace the cables. They do sell new replacements, but after watching my wife do this on her '96, I can say it's some very finicky and tedious work.
Mine seized up earlier this year after I hadn't used it for a while, but I was able to coax it back into moving, and then spent a while trying to clean and grease it, and it's back into normal function. I just try to remember to use it frequently. Pop it into vent mode, open it, close it. Far more likely for it to stick again than it is for me to wear anything out on it.