
A battery works on the principle of an electric cell (read more about it here). Common batteries we get in shops have a mixture of manganese dioxide and zinc powder. These are also called alkaline batteries. The electrolyte of an alkaline battery is made of potassium hydroxide (KOH), a very toxic chemical. If it leaks, it can irritate the skin and eyes. These batteries also contain a small amount of mercury, another very poisonous chemical.
When you slot a battery in a device like a camera, the zinc in the cathode reacts with the KOH, releasing electrons. Now that an electric connection is available, the electrons move through it to the other end of the cell, powering the camera on the way. Here they react with the manganese dioxide in the anode. When all the zinc powder in the cell is used up, it stops giving electric power. Then you have to throw the battery away.
In a lithium ion battery, the anode is made of graphite, and the cathode of lithium manganese dioxide. The electrolyte has a mixture of lithium salts.
When you put the battery in a device, the forward reaction happens. The cathode releases electrons and they pass through your device powering it, just like an ordinary cell. Lithium ions pass into the electrolyte. The electrons come back to the anode, where they are taken up by the graphite.
When you charge a lithium ion cell, the reverse reaction happens. Electrons come into the cell from the electric socket. They get taken up by the lithium ions in the electrolyte. These then get deposited back on the cathode. So when you use the battery again, it is able to give you power by going through the forward reaction again.
Rechargeable batteries cannot be recharged more than three or four times. That's because the chemicals get heated up while being charged, and react to form other reactions. These cannot be reversed. So don't leave them on for too long. You can make a rechargeable battery last longer if you keep it in the fridge!