Buck converters work by switching on and off at very high frequencies. Examine the schematic below. The circle on the left is a voltage source at say 12V. The rectangle on the right is a load that we want to power with say 3V. Let's call the bottom of the load ground and define that voltage as 0V.
Examine the inductor and the capacitor as a pair. Together they act as a low-pass filter with the input on the left and the output on the right. Refer back to Buck Converter Concepts: LC Low Pass Filters if you don't remember how LC filters behave.
The voltage at the input of the LC filter can be one of two values: 12V when the high side switch is closed or 0V when the high side switch is open. It's obvious why the voltage is 12V when the high-side switch is closed. Why is the filter input voltage 0V when the high side switch is open?
The current through an inductor cannot change instantaneously. When the high side switch is closed, current is flowing to the right through the inductor. After the high side switch opens, current continues to flow through the inductor to the right. This draws current upwards through the diode. Since the diode is forward-biased by this current, the voltage at the top of the diode is equal to the voltage at the bottom of the diode minus the forward voltage of the diode. If we assume the diode is an ideal diode, then the forward voltage of the diode is 0V. Therefore, the voltage at the bottom of the diode (0V) minus the forward voltage of the diode (0V) gives the voltage at the top of the diode (0V).
Turning the high side switch on and off produces a square wave at the input of the LC filter. As we saw in Buck Converter Concepts: Frequency Content of Square Waves, square waves have a DC component and some frequency content at frequencies that are integer multiples of the wave's fundamental frequency. When properly designed, the LC filter removes everything but the DC component of the square wave.
In our example, the input voltage is 12V and the output voltage is 3V. If we turn on the high side switch for 25% of each cycle, then the average voltage at the input of the LC filter will be 3V. The high-frequency components of the square wave get filtered out, and only the smooth DC voltage of 3V shows up at the output of the filter.
Extra Credit: Why is the diode necessary? If the diode is not present, the switch would be destroyed. Suppose the load draws 1A of current. This means that the current through the inductor is 1A when the switch is closed. When the switch opens, the current through the inductor remains the same; the inductor current cannot change instantaneously. The resistance of the switch when it is open is some large but finite number. Let's say it's 10Mohm. Given that the current is 1A, and the resistance of the switch is 10Mohm, the voltage across the switch would be V = IR = 1A*10Mohm = 10MV. That's a huge voltage! (The dielectric breakdown of air occurs at about 3MV/m. A voltage difference of 10MV could arc over three meters through air!) This huge voltage will arc across whatever gap is present in the switch and cause catastrophic damage to the switch.
Photo by Paul Cross