Why is the voltage of a car battery rated for say 12V around 14V when the car is running? Is it because of the alternator?
All batteries vary in voltage base on charge state and on loading.
A 12V lead acid battery is 12V nominally. This means that 12V is a about middle of the range of the battery. A fully discharge 12V lead acid is around 11V, fully charged it's about 14 to 15V.
Lithium Ion batteries are the same: 3.6V nominally but really they vary from 2.9V to 4.2V (there is variation in this depending on the precise cell; I've seen some Samsung ones got down to 2.5V for example). This is why you sometimes see prodcuts which are "42V" having the same power as a 36V battery pack, they've just used the maximum voltage to make their product seem better. This is legal in the EU and USA, though the ethics of it are questionable.
As for the second part of your question: the car goes up to 14V because the battery is being charged up, yes from the alternator (or other power source). To push power into the battery, you need a higher voltage than the current battery state. As a general rule you have a current limited voltage source, which charges the battery. Back to Li-Ion cells again (as that's what I've has most experience of) we use 4.4V per cell to work out the charging voltage (which is why if you look at chargers they are always higher voltage than the battery they are charging). For a car it is similar, often 15.2V is chosen as the charging voltage to balance safety (lowest voltage possible) and charging time (highest power possible). You're only seeing 14V for a combination of reasons: the car may keep the voltage lower to save over charging the battery pack and the current limit has taken effect, so the voltage as dropped.
You are absolutely right, it is because of the alternator. When the car is running the alternator is set to generate around 14 volts which not only charge the battery but also supply all electrical requirements of the car. The battery is only used to start the car or for lighting some bulbs and other accessories when the car is not running and the alternator is therefore not generating any power. Once the car has started, thereafter even if we remove the battery the car would keep running till the engine is switched off intentionally or due to any other reason. For starting the car again it would need a battery. When one is driving a car and the alternator fails due to some reason the car would keep running till such time the battery is able to supply power. However, since all the power requirements of the car in such a case are met by the battery, it would get discharged quickly. Therefore, it is necessary to get the alternator repaired at the earliest. when the alternator fails, the battery warning lamp would light in the display panel indicating that the battery is not getting charged.