Flashes allow the photographer to illuminate their subject, play with light, and take usable photos in conditions that would otherwise be impossible.
Most modern cameras communicate with a flash using a hot shoe that has electronic contacts within a metal accessory mount. The amount and position of these contacts vary by manufacturer, so be sure to get a flash that is compatible with your system.
Older flash systems will only one electronic contact. This means the flash will only fire in manual mode, and the photographer must consult the flash and their camera to determine proper focus, aperture, and shutter speed for flash use.
Even older cameras won't have any electronic contacts at all in their accessory mount. This is what's called a "cold shoe", and it will only hold a flash in place. Cameras like this will likely have a PC sync port, which requires a PC sync cable to attach a flash to the camera. Otherwise, the PC sync system works similarly to manual flashes.
There are many flashes out there, but the general rule is that new flashes will work on all cameras and older ones may not work with newer cameras. There are voltage differences that could even damage modern digital cameras if you use them with a vintage flash.