Cockpit doors stay open during boarding to help pilots and crew coordinate final pre-flight tasks—before being locked for safety once the plane leaves the gate.