Because there is another circuit. The buzzer has its own circuit. When the window circuit opens,
How does this happen?
The buzzer circuit has its own battery, an electro-magnet and relay switch. This is how it works :
1. The window circuit opens.
2. The electro-magnet in the window circuit to switch off.
3. The electro-magnet releases the relay switch on the buzzer circuit. This allows the spring to push the switch. The buzzer circuit closes.
4. The current flows from the battery around the buzzer circuit. This makes the buzzer produce a loud noise.