If the polarity changes every time the AC switches, then why doesn't the capacitor explode?
As clabacchio said, some capacitors are unpolarized, so it's perfectly fine to put positive and negative voltages on them.
However, it is still possible to put a AC signal thru a polarized capacitor. This is done by adding a DC bias of at least half the AC peak-peak voltage. The entire signal is then still positive, but AC-wise the capacitor acts on it normally.
Nowadays, polarized capacitors are mostly used for bulk storage on power supplies to reduce ripple and to provide short term high current. A nominal 12V supply, for example, may have 1Vpp AC ripple on it. That means the voltage is from 11.5V to 12.5V, which is fine for a electrolytic or other polarized cap. However, the large value of the cap will be applied to providing current to counter the 1Vpp AC voltage swing.
Put another way, polarized caps must always have a positive voltage on them, but there is no such restriction on current.
Because not all the capacitors have a polarity. As far as I know, only electrolytic capacitors have a fixed polarity, while for instance ceramic capacitors don't.
If you look at the schematics, you will see that (in proper designs) electrolytic, or in general capacitors with a polarization, have the negative shield curved and a plus sign in the positive shield; the other capacitors are symmetric, so you cannot say which is the direction if not by the label.
You must know what capacitors are used for. That will clarify where polarized capacitors are used. They are not used in AC Circuits.
Capacitors are used in turning circuit in AC. These are non polarized. So as the AC switches direction, it cannot damage the capacitors because the capacitor is simply not polarized and can be plugged in either direction.
Electrolytic Capacitors (which are polarized) are used in Smoothing out ripples in DC. They are polarized and large. The act mainly used in rectifiers. The are essentially DC circuit in which the signal does not change polarity.
So true if you put an electrolytic capacitor (polarized) in an AC circuit, it will easily get damaged provided it exceeds it rating.