There are all sorts of reasons, but the most common are:
a car being left unused for a while, or only used for short journeys
a light being left on
a faulty component
a problem with the car’s charging system
a fault with the battery itself
Batteries can fail for other reasons too. Excessive vibration, over-charging, corrosion and extreme heat or extreme cold.