At the core of the physiology of stress is a thing called 'fight-or-flight response'.
Let's say you decide to go for a walk in nature because the weather is quite nice outside. As you are strolling along, suddenly a tiger appears. Before you finish thinking 'what the fuck?', your subconscious already recognized a subconscious threat and is taking appropriate measures.
Your blood starts pumping like crazy, and shots of adrenaline, endorphins etc. released into your body. Your brain switches into a higher state of awareness, one second seems like ten, and you become acutely aware of your mortality and the miserable situation you are in.
But, you are lucky and the tiger just walks away without showing any interest in you. Your subconscious is acknowledging that the threat has passed, and although your heart is still pumping, you slowly begin to calm down.
In this case, stress has accomplished its purpose. At a crucial moment, it allowed you to perform many times better than normally - and then it went away without causing damage.