The alternator, which is driven by the engine, generates electricity that is used to power the car's electrical system and charge the battery. When the engine is not running, the alternator is not generating electricity and the battery is not being charged.
If the battery is not charged, it will eventually become depleted and the car will not be able to start.