First off, if you want to read up on batteries in detail, go to Battery University as a starting point. I'm not even trying to go close to their detail.
There are areas where solar power is the only source and once the sun has gone, the power supply is shut off but a very common scenario is to store the generated energy for use when the sun isn't shining. This is where energy storage comes in.
There are lots of ways of storing energy, but for large scale storage, electricity is rarely stored itself and is instead converted into another form which it can be regenerated from. The title says 'and batteries' so a big part of this bit is batteries, but just to give a few ideas, other energy storage ideas can be:
These are all useful in their own way, but using all or even some of them can use up a lot of space, and on the whole the smaller practical solutions are what we most want.
Before moving on to batteries, the most common man-made energy storage is in the form of capacitors. Details for capacitors can be extensively covered by Wikipedia. These are electrical devices which store electricity without converting the energy to another form. There are newer practical capacitors that can store large amounts of electricity but they can be complex to implement, most everyday capacitors store enough electricity for a few fractions of a seconds use and even the larger ones might run for a few seconds. They do have a use though, but I'll cover that in this section here. One thing different between capacitors and other energy storage, is that they are very efficient, there being no conversion involved, but that doesn't always equate to useful electricity stored.
Batteries aren't in the list above, but the core function of batteries is to convert chemical energy into electrical energy through a physical arrangement of chemicals and conductors. In many instances, this is a one way arrangement, with chemicals being discarded after use, but rechargeable batteries make the arrangement reversible and aim to retain the chemicals used for reuse many times, converting electrical energy into chemical energy and store the energy for long term use.
It's rare that the chemicals used in energy storage are safe to living organisms, including humans, and the more efficient they are, the less safe they are. For example, common lead-acid batteries are full of lead and sulphuric acid, both of which are very harmful to life, but they are easy to make and use. Treat batteries with respect, don't discard them randomly in the environment, but seek out ways of recycling them.
As this is about energy storage, then there has to be a measure of capacity, but it's rare to find any battery manufacturer that quotes storage capacity as the actual chemical constituents, and almost always the the capacity quoted is the converted electricity value. So, the figures advertised for a battery are typically ampere (amp) hours (Ah) or Watt hours (Wh) of converted electricity.
Battery manufacturers can be inventive as to how to specify the capacity of their products to put them in a better light than their competitors, but the standard capacity is quoted at a constant discharge rate of one twentieth of the capacity quoted. So, a 100Ah battery, is quoted as being 100Ah when it is supplying 100/20A or 5A for 20 hours, and when new, that battery should be capable of doing that.
So that's the measure of the batteries capacity. If you only want to run 5A loads then you have a good measure of how well your battery will do.
The downside to this is that this is only one figure and batteries are chemicals not mathematics. The more current that is used from a battery at once makes it less efficient, and so the 'capacity' of teh battery changes. Again, the battery is a machine for converting chemical energy into electrical energy, not a guaranteed source of electricity. So, if instead of 5A, the load current is 10A, then the apparent capacity of the battery might drop to 95Ah. If doubled again to 20A, it might only be 75Ah, and if doubled again to 40A, might only be 40Ah!
As a converse to this, reducing the load to 1A might give a capacity of 110Ah.
So the capacity of the battery to supply electricity is dependent upon the electrical load that is put upon it. Different battery technologies do vary their efficiencies, which is one of the advantages to choosing different types.
It's not a perfect analogy, but being machines, batteries can wear out and become more inefficient with use and age. There are different reasons for this based on the chemistry and construction of the battery, and manufacturer's will quote lifetimes in terms of recharge cycles and depth of discharge. The way in which this is quoted varies on how the manufacturer wants to portray their product, but a typical figure might be 500 complete recharges, with the view that you could get 1000 recharges if only 50% empty each time. The 50% level is a very common quote, called 50% depth of discharge, and again 500 recharges at 50% DoD is a good example.
The lifetime, of course, is what you make of it, but generally its taken to be the point when the battery no longer holds enough energy to make it useful for its purpose. Batteries loose capacity just by existing, or if they are heavily used at high discharge rates, if they are regularly flattened without being recharged, all shorten the lifetime of a battery. Some manufacturers do give full details of their batteries operation and this can help understand exactly how a battery will function to create electricity.
The efficiency of a battery is very dependent upon temperature, with batteries increasing efficiency with temperature. Increasing temperature can bring other factors which damage a battery, but a batteries capacity to generate electricity can be significantly impaired by the battery being cold, and then revived when the battery is warmed up. Ah capacities also come with a temperature at which the value is valid, warming a battery up can give increased capacity, and one big manufacturer warns that in their case, their batteries may only have 50% capacity at freezing as quoted at 20 Celsius.
At the end of this, battery capacity has many factors which affect it, but the main take away is that if you want a battery capacity you can depend upon then don't use the batteries heavily, keep them charged and keep them warm. When a battery is used, recharge it as soon as possible.
Battery lifetime is both an economic and convenience consideration. It really is not without reason to use batteries however is wanted, and then replace with new ones every six months or a year. If cost isn't an issue, and a regular schedule isn't a problem, then that might be fine. Many people are careful with the resources they use, so if driving a vehicle, they make sure they keep fuel consumption to a minimum, and so save money. Driving without regard to fuel consumption can easily rack up big fuel costs, so much so that the economics of regular battery changing are on par. If trying to reduce battery turn over and the associated costs, then its the same as frugal driving.