How does this buzzer volume regulation work?
The code is not setting pins to high or low (VCC or GND), but is instead disabling the output entirely. If you examine the circuit with two pins disabled, neither sourcing nor sinking current, it will make sense.
Consider, for example, PWM2 and PWM1 as outputs and PWM0 and PWM3 as high impedance (for these purposes we can treat them as disconnected). The current must pass through R19, as it can't pass through PWM0. The voltage across the buzzer is decreased as it is effectively forming a divider with R19, and the volume decreases.
If you consult the datasheet for the microcontroller (possibly in the XMEGA line?), you should find a diagram of the GPIO pins, including which registers control them. The code is simply reconfiguring the unused pins to be inputs (disabling the output drivers), and enabling the output drivers that include the appropriate resistors.