How it works:
From left to right, the first part is the input stage, here is the connector to the audio source connected too the circuit using a capacitor. This capacitor passes only the audio, and blocks any direct current that may affect the function of the amplifier. Next to the capacitor is a variable transistor (potenciometer), this is used as a volume control.
Next is the LM386 itself, this amplifies the audio input using energy from the battery it is connected to. You'll notice there are two capacitors connected to it, one above and one below in the schematic. The top one is connected from pin 1 (positive side of capacitor) to pin 8 (negative side), this is to get the maximum amplification this IC can generate. The bottom one is also there to help get maximum amplification, this one goes connected from pin 7 (positive) to ground.
Last is the output stage, it is made with two capacitors, one resistor and the speaker. The resistor and capacitor that are connected before the speaker form a filter, that attenuates high frequency signals coming from the amplifier, most likely noise picked up or generated in the amplifying process. The capacitor connected to the speaker is there for the same reason we used a capacitor in the input stage, to prevent direct current from causing undesired operation of the speaker.
(click to enlarge)