It may not be a Porche issue ... It may be an aftermarket install.
There is probably something wrong with the Total Closure Relay or the Sunroof position sensor. These have to be set up correctly so the alarm knows when it is open or closed, before it can decide what to do with it on arming the alarm.