The alternator is responsible for charging the car battery and powering all the car's onboard network consumers. If it fails or is unstable, the battery will either not be charged or start discharging ...
The reality is that like almost every component under the hood, a car battery has a finite lifespan and will conk out on you eventually. Weather conditions, corrosion, electrical shorts, charging ...