Batteries work by the transfer of electrons to produce electricity. The flat end wants to get rid of electrons while the nubbed part wants more and this action produces activity.
Batteries use acidic chemicals that are good at storing electricity to hold their charge. Then when a battery is placed inside a device, the electrical current of the device is completed by the charge held in the battery.