Your circuit looks like a buck dc-dc converter.
There are several reasons capacitors are used. The electrolytic cap is there to provide a stable DC voltage to the switch. Output pulse width is calculated based on input DC voltage. If it changes during the pulse, an output error will result. Amount of capacitance required is determined by the output load and type of DC supply. For instance, single phase, 6, 12, 18 pulse rectifier, active front end, battery. The active front end would require the least amount of capacitance where the single phase rectifier would require the most.
Also, there will ALWAYS be impedance in the DC link to the switch. A snubber capacitor would be used to absorb the energy in the inductance and prevent large voltage spikes across the switch. Remember, V=L*di/dt. The di/dt of that switch is very large resulting in a very large voltage spike across your switch. If your switch is a FET, the large Vds caused by this inductive spike can destroy the FET. Snubber caps are usually ceramic or film type caps.
The inductor is there to allow the control circuit to either control the current or regulate the voltage. The inductor does the same thing in both cases, limits di/dt.