Hi,
Do you know about fourier series? It is used to represent any periodical waveform with the sum of many many sinewaves.
PWM is square wave that is the sum of constant, fundamental frequency and infinite of harmonics. The average voltage for the PWM signal is actually the constant value, which is a0/2 in fourier series.
To get the constant value, a low pass filter is added at the output of the PWM signal to remove the fundamental as well as the harmonics.
Check out the application notes from Microchip. Using PWM to Generate Analog Output