Before tapas was a discipline it was a cosmogonic force. The Rig Veda's hymn of creation, the Nasadiya Sukta, reaching for how anything came to be when there was neither being nor non-being, says that That One was born through the power of tapas, heat. The same word covers the brooding warmth by which a bird hatches its eggs, and the Vedic poets used exactly that image: the world as something incubated, sat upon, heated into existence.
Later Vedic myth made the pattern standard. Prajapati, the creator, heats himself with austerity until beings stream from him; sages accumulate tapas the way kings accumulate treasure, and the gods watch nervously, because sufficient heat can compel them. Whole epic plotlines turn on an ascetic whose austerities have built such pressure that boons must be granted to vent it. This mythology is the background radiation of the third niyama.
When Patanjali prescribes tapas, and promises at sutra 2.43 that it destroys impurity and perfects the body and senses, he is domesticating an ancient physics: the practitioner's fasting, vigil and endurance are small applications of the same force that incubated the cosmos. The metallurgical image the commentators prefer, fire refining ore, keeps the physics and adds the ethics: heat does not create the gold, it burns away what is not gold, and the discipline is calibrated, not maximal, because a fire too fierce destroys the vessel.