As others have stated, the capacitors and inductors are commonly used for filtering out ripples by smoothing the peaks and valleys. There are lots of websites that explain the math formulas related to using these as filters.
But fundamentally it's important to understand what's actually happening. Both of these components store energy, but they do so in different ways. Capacitors store it as static electricity. Inductors store it as magnetic flux.
This causes them to behave differently, and rather oppositely, to changes in voltage and current.
Capacitors try to keep the voltage the same at the expense of collecting or releasing as many electrons as it can manage. In an analogy of water, one can think of a capacitor as a pipe with a flexible membrane sealing the middle of the pipe. The pressure on one side of the pipe may go higher and lower, as compared to the other side of the pipe, and in doing so the flexible membrane will stretch back and forth to compensate for the pressure changes. Does the move the water on either side? Sure it does. This will be the alternating current "moving through". But does the water simply "flow" through the pipe? Not really. It's moving back and forth, but it can't actually flow through because of the flexible barrier sealing the middle of the pipe.
Inductors try to keep the current the same as the expense of collecting or releasing as much magnetic flux as it can manage. In the same water analogy, one can think of an inductor as a very long pipe, or tube. Anyone that has carried a pale of water up a hill can tell you that water has mass, or "weight", and things that have mass can also have inertia. Water, having mass, moving through a long pipe will have inertia. Any water in the pipe will want to remain still if it is already still, and will want to remain moving if it is already moving. The speed of the water in the pipe can speed up or slow down, but the inertia wants to keep the flow rate steady.
Put these two pipe systems together in a design similar to the filter circuit above and it will tend to behave the same way. As the source pressure increases or decreases, as from the pulsing DC voltage coming from the rectifier bridge, the first flexible membrane will stretch to absorb the initial increase in pressure. At the same time the long pipe will resist an increase in quantity of water, but will gradually allow it to increase. The second flexible membrane pipe will also stretch to absorb the pressure changes between the long pipe and the load.
This is what's happening in the "pi" filter above. The inductor is trying to keep the current flow steady, at whatever current flow it is currently at. The capacitors are trying to keep the voltage steady by collecting and releasing electrons from and to the circuit.
Generally speaking, adding more capacitors and inductors will result in better filtering, or less fluctuation. But like many things in life, there comes a point were more isn't better. At some point adding more components only increases cost, size, complexity, etc. There's also the continually nagging issue of working with imperfect components. An ideal capacitor or inductor will have exactly 0 ohms across it at any given voltage or current. But we make capacitors and inductors out of imperfect materials, so there is always going to be some amount of resistance added with these components. This resistance will cause some of the energy to be released as heat. Heat is wasteful and generally the enemy of any circuit, unless you are actually trying to build a heater. This tends to cause designer to add as many as needed and no more, or not much more.