First I want to address some fundamental capacitor properties for you to consider:
- Certain capacitors have specific polarity markings that you need to take into account and insert them correctly into your circuit. Not doing so can cause damage to your components. If you don't see any indication of polarity, you should be okay with either direction you place it.
- As briefly mentioned in another answer, capacitors are "energy storage devices", specifically charge. Current is simply the flow of charge carriers, so a capacitor will prevent this flow while it is charging and when it discharges, the current will flow.
So, think about the circuit implemented in user8055's answer. A switching circuit needs to be thought of as 2 pseudo-independent circuits
First: When the switch is initially creating the smaller circuit of the DC source and the capacitor, charge builds up in the capacitor. As long as the switch is in the first position and not connected to the resistor/LED branch, this charge will not go anywhere and current will not flow, as the capacitor is fully charged due to the source constantly supplying voltage to it, thus keeping it in an equilibrium state.
In this first state, think of the capacitor as a fully charged battery.
Second: As soon as the switch flips to the other branch, the capacitor is no longer being supplied with power, and it begins to discharge. This discharge creates a movement of charge carriers (current) that passes through the resistor and LED, lighting it up. Make sure you notice the DC source isn't actually powering anything at this time, as it isn't part of a complete circuit. The only source of energy is the charged capacitor. Eventually, the capacitor will fully discharge, and the current will stop flowing, thus the LED turning off, due to not having any power source.
Another thing to consider is how a capacitor will work when the circuit is driven by an AC source, instead of DC. Depending on the configuration of the resistor and capacitor in the circuit, this is how filters are created to restrict specific frequency ranges.