It can be one of the most annoying things to deal with; a car battery that seems to randomly die.  The problem with repairing this sort of thing is that sometimes it's the battery, sometimes it's the alternator, and sometimes the car's wiring, at fault.  Even seasoned mechanics can be buffaloed when troubleshooting a randomly dying battery. That being said, if you have a misbehaving battery, here's a few things to know:

Faulty Charging System: It's the responsibility of the alternator in your car to keep the battery charged. If it provides a charge that's too high or too low, then you have a problem. Technically a fully charged battery produces 12.6VDC voltage.  To charge a battery properly, an alternator must pump out 13.4V-14.7VDC.  If the alternator isn't working and isn't putting out 13.4V-14.7VDC then it may be failing to charge the battery correctly.  This can occur due to a loose connection, a bad circuit, or just a faulty alternator. A qualified automotive mechanic can easily check this for you.

Short-Term Driving: Driving your car often on short trips can contribute to a short battery life and a battery failing to keep a charge. This is because the most taxing use of the battery in your vehicle is the initial engine start and you never give it enough time to get fully charged.  When in doubt, drive around for 10 mins or so just to keep a decent charge.

Extreme Temperatures: Extreme cold and/or heat can stress the internal chemistry and structure of a car battery and induce premature failure and random dying.  In most cases, there isn't much you can do about temperature extremes but it's a factor that you should know about.  Chemically what goes on is called "sulfation".  It's a build-up of lead sulfate crystals which can shorten the life of the battery and lengthen the amount of time needed to charge it.  

Excessive Current Draw:  There are devices in your car that will draw a small amount of current to stay on.  Things like your clock circuit and other items. Normally this sort of thing won't kill your battery however, if you have an excessive current draw due to a short circuit or fault of some sort, then your battery may die before you get a chance to drive your car again.  Of course, leaving a light in your car on will do the same thing as we all know. 

Losing a battery once a year for three years indicates something is wrong.  Same with a battery randomly dying. When in doubt, consult a professional mechanic to find out what the problem is.