What capacitors do when it is connected in Series and parallel to a AC input
Back to basics, Q = CV i.e. amount of charge in a cap = capacitance x voltage across it.

Differentiate to get \$\dfrac{dQ}{dt} = C\dfrac{dV}{dt}\$

Rate of change of charge is current therefore: -

Current in capacitor = \$C\dfrac{dV}{dt}\$

When in parallel with an AC source the current is the differential of the voltage multiplied by capacitance. Presuming that the voltage source is sinusoidal you'll find that current is also sinusoidal and leading the voltage waveform by 90 degrees: -



And for fairness I've shown what it looks like for inductors too: -



When the capacitor is in series with the supply the current depends on how much load resistance is connected to the output of the capacitor and this will produce a current that is somewhere between being in-phase with the supply voltage and leading by 90 degrees. This is dependent on the values of the load resistor and capacitor.

In the top circuit shown by the OP, the capacitor acts as a controlling impedance thus dropping voltage and controlling the current through the LEDs. And, because the voltage across the cap and current through the cap are always 90 degrees apart, the capacitor does not theoretically dissipate power.  resistor dropper would generate heat because voltage and current are in-phase.