Well, a failing alternator won’t charge the battery, so the battery ends up getting drained as a result.
They tend to put as small of a battery in a car as they can get away with, which is why they die after only a few years. Put in a larger battery (the most cranking amps you can get that still fits in your vehicle, space is usually limited) and the battery will last for 15 to 20 years, easy.
You don’t need a fancy auto-shop computer for most alternator failures. Measure the battery with a voltmeter. It should be somewhere around 12.6 volts if fully charged, a bit less if it’s been drained. Below 12 volts is really bad and the battery might not fully recover when re-charged. When you start the car (might require a jump if the battery is drained), the voltage should go up by a volt or two. If the voltage doesn’t go up, then the alternator isn’t working.
If you jump it from another car and let it charge for a bit, you should have enough battery power to drive it to a shop to get the alternator replaced, assuming you don’t live way out in the sticks and have a 45 minute drive to town or something like that. Turning on the headlights will rapidly drain the battery though. It’s best to do this during the day if possible.
A lead acid battery is made up of two sets of plates. In each “cell”, one plate is lead and the other is lead oxide. There’s a mixture of water and sulfuric acid in between the plates, which acts as the electrolyte. As the battery discharges, both plates turn into lead sulfate, and the sulfuric acid turns into water. Each cell puts out a bit over 2 volts. There are therefore 6 cells in a car battery for a bit over 12 volts fully charged (6x2=12).
More surface area on the plates gives you more cranking amps. Thicker plates gives you a longer discharge time. For a given amount of lead, you can either have thinner plates with more surface area for higher cranking amps or you can have thicker plates that can crank for longer but have less cranking amps. Car batteries tend to have very thin plates, so they put out a lot of cranking amps to start the car but they don’t last very long if you keep cranking. “Deep cycle” batteries have thicker plates.
If the battery gets discharged too far, the lead sulfate forms hard crystals that don’t break up during recharging, causing a permanent loss of capacity for those part of the battery plates. If the battery has been discharged to the point where the interior lights won’t even turn on, the plates are probably heavily sulfated and the battery is shot.
You were wise to get it replaced.
This is also why the undersized batteries they put in cars these days (to save weight and money) only last a few years. They tend to get discharged too far just through normal use and permanent sulfate crystals build up on the batteries. Putting in a larger battery so that it never gets discharged far enough for permanent sulfate crystals to form solves the issue.