The issue may stem from either the sunroof seals being excessively worn, allowing excessive water ingress, or the drains in the sunroof's catch pans being obstructed.
To access the two drain lines leading to the rear of the car and the two extending to the front inside the driver door frame, you must remove the headliner.
If water is poured into the pan of an open sunroof and fails to drain, the little drainage holes may be obstructed. This occurred with my 2015 435i Gran Coupe and damaged my headliner.
With the headliner removed It would leak onto the backseats.