Here's a fun fact: not all motorized machines require a battery to operate.
Sure, an electric starter needs a jolt of juice from a battery to fire up an engine but, once underway, there are cases where a battery isn't needed at all. If there aren’t any accessories such as lights, some vehicles run just fine without a battery!
But, as we all know, modern road-going vehicles have plenty of features and accessories that are hungry for electricity. Modern batteries in gas-powered cars are primarily responsible for what engineers call SLI - starting, lighting, and ignition. Once the vehicle is running, an alternator supplies a current to systems that need electricity and sends some juice back to the battery so it's ready for the next starting cycle. The battery can also serve as a voltage stabilizer, absorbing random power spikes that might otherwise damage sensitive car computers or sensors.