We have spindle cells in the belly of the muscle which trigger a stretch reflex, which is a contraction in the muscle as its getting longer, this is a mechanism to protect from overstretching. The theory is that if you want to stretch further, you need to let these spindle cells get used to being longer. The counterpart to the spindle cells are the golgi tendons which live in the place where the muscle attaches to the tendon. This can protect the muscle by overriding the contraction, forcing the muscle to relax. The spindle cells and golgi tendons work in opposite ways, for example if I wanted to switch a muscle off I could just push together in the belly of the muscle. Luckily for us, during resistance stretching, if done correctly, we will override all this and won’t need to use our stretch reflex as we will be working in a safer range of motion.
Studies show that it can actually increase the risk of injury if we stretch directly before exercising as a warm up, however, stretching has many great, proven benefits when carried out at all other times.