Energy storage.
Suppose you have a linear 5V DC supply running off 110V AC. You might use a stepdown transformer to 10V AC, a bridge rectifier, and a 3-terminal regulator. The regulator needs at least 8V to work, but the output of the rectifier is rectified AC which goes to 0V 120 times a second. So you use a capacitor to store energy between the peak of the waveform which is I think 14.1V, and the next time the voltage rises to 8V some 8ms later. The charge stored is CV=IT so the maximum current you can supply I is about CV/T or about 0.7A for a 1000uF capacitor. Yiou can adjust the formula for different AC frequency, voltage drop, and desired current to find the value of capacitor needed. It's not for smoothing out fluctuations in the AC, it's for providing your peak load when the input voltage is too low.
You might use a smaller low-inductance capacitor on the regulator output for filtering.
When you convert AC to DC using bridge of diodes, still you get fluctuating positive cycle, which goes from vmax to 0 as per the frequency of line. Capacitor, stores some energy and releases it Whenever voltage drops towards 0, thus providing you smooth DC supply. That's why capacitor is placed in parallel, in technical language, it bypasses any alternating current, and sends dc front. I hope you understood my language.
The tank capacitor in a power supply is very large and stores charge to supply current when the demand surges suddenly much the same as a water system tank supplies large demands for water and prevents the pressure(voltage) from dipping too far before recovery, they operate very similiarly.
I've answered so many similar questions I've written some web pages about this. Check the link.
For filter.