A capacitor is an electronic component that charges by accumulating electrical charges, then discharges by rapidly releasing them.
When the capacitor releases its electrical charge, it performs a power supply function, acting much like a battery.
However, unlike a battery that releases its energy slowly, a capacitor releases all its energy at once. After being discharged, the capacitor must recharge before it can be used again.
A capacitor consists of two conductive layers separated by an insulating layer.

When the capacitor is charged, electrons accumulate on the conductive layer connected to the negative terminal of the current source. These electrons cannot cross the insulating layer to the second conductive layer, which creates a charge imbalance between the two conductive layers. This charge imbalance produces a potential difference, also known as voltage.
It is this potential difference that is used as a source of energy when the capacitor discharges to power a device.
A circuit inside a camera contains a capacitor that accumulates charges thanks to the camera's battery. When the flash is activated, the capacitor discharges to power the flash.
The following simplified electrical diagrams show how the capacitor charges and then discharges.

Source: Adapted from Koldunov, Shutterstock.com
When the capacitor is charging, the switch in the battery loop is closed. This creates a potential difference between the two conductive layers of the capacitor.
When the capacitor discharges, the switch in the battery loop opens and the switch in the flash loop closes. The potential difference between the two conductive layers generates the electric current required to power the flash.