How does electricity work?
I’ll assume that you are asking about moving or dynamic electricity, the type that lights the bulb in a flashlight (as opposed to static or stationary electricity). In that case, you are referring to a flow of electric charges that is generally called an electric current. This movement of electrically charged particles carries with it energy, both as kinetic energy (energy of motion) in the charged particles and as potential energy in the electrostatic attractions and repulsions of these particles. The particles typically acquire this energy from a battery. The battery pulls opposite charges away from one another and pushes like charges together. These actions increase the energy of those charges. The charges then rush through electrically conducting materials, generally metals, in order to bring opposite charges closer together. This flow of charges releases the energy given them by the battery.
In a flashlight, the batteries provide the charges with power and the light bulb makes use of the power. The charges first flow through the battery (which gives them energy), then through wires to the light bulb, then through the light bulb (where they give up their energy), and finally back through wires to the battery. The charges move in a loop—a circuit—so that they don’t accumulate anywhere. They travel endlessly between battery and bulb, shuttling energy from the battery to the bulb. As is always the case in electric circuits, two wires connect the battery and bulb—one wire to carry charges to the bulb and one wire to return them to the battery to begin their trip over again.