People used to be worried that they would be attacked by spirits on the anniversary of their birth, and so clustered with family and friends in order to keep themselves safe. This quasi-religious aspect to a birthday "celebration" continues.
We have birthday cakes because either the Greeks made round cakes to venerate Artemis, goddess of the moon, or because the Germans made a special bread (which might be called Geburtstagorten and might not) in the shape of the baby Jesus' swadding clothes. The candles were an extension of these cultures. Gibbons stated in 1986 that the Greeks put candles on their round cakes to make them glow like the moon, hoping to gain Artemis' special favour. Alternatively, the candles were intended to carry the birthday wishes up to God (or the gods utilizing candle magick depending on belief systems), along with the smoke. Some Germans even today place a large candle in the centre of a birthday cake to symbolise the "light of life" (from Corwin, 1986).
Adding a number of candles that correspond with years is a fairly obvious extension of the general candles-on-cakes principle, once you're into it anyway. Blowing them out is, I suspect, just done because it's fun to blow out candles, now that the religious aspect has faded away somewhat. Besides, if you don't blow them out then you can't inflict on people those trick candles that relight, which would be the end of a venerable birthday tradition.