Flashing order is what keeps water out
Every layer around a window has to shed onto the layer below it, the same way shingles do on a roof. The sill pan goes in first so anything that gets past the unit lands in a tray and drains back out. The window is set and fastened. The jamb flashing laps over the sill pan, the head flashing laps over the jamb flashing, and the house wrap laps over the head flashing. Done in that order, water always has a path down and out.
Reverse any one of those laps and the same detail funnels water into the wall instead of out of it, where it rots framing and shows up as a stain on the drywall long after anyone connects it to the window. This is the step that separates a window that lasts from one that becomes a repair, and it is invisible the moment the trim goes on.


