It is because the surrounding air of the flame becomes hot (and hence low dense). This low dense air now raises and new (cold or dense) air will come in contact with the flame. This air also gets heated up and raises. This process repeats it self. This raising air is what actually shapes the flame.