Your sunroof is likely accumulated dirt and grime over time within the cable guides. The sunroof assembly is rather simple. The top half drops in from the top of the roof and is sealed with a thins adhesive tape. The inner pan is installed from within the vehicle and is screwed to the top half with several torx screws. The top section has flexible cables that almost act like threads on a screw that drive the action of the glass. Sometimes those cables get dirty or the grease deteriorates and those cables will slowly seize causing what you are experiencing.
I mean you might have a blockage in the track...definitely check that first. But to repair, you will probably have to drop the head liner carefully, disassemble the sunroof assembly, and work those cables free and then clean and re-grease.
You can also take this time to make sure the drain tubes are not clogged and corners of the inner pan are sealed properly to prevent future common leaks.
"Out of every one hundred men, ten should not even be there, eighty are just targets, nine are the real fighters, and we are lucky to have them for they make the battle. Ah, but the one, one is a warrior, and he will bring the others back"