This is something I have wondered about for a long time.

When the muscle is stretched, so is the muscle spindle (see section Proprioceptors). The muscle spindle records the change in length (and how fast) and sends signals to the spine which convey this information. This triggers the stretch reflex (also called themyotatic reflex) which attempts to resist the change in muscle length by causing the stretched muscle to contract. The more sudden the change in muscle length, the stronger the muscle contractions will be (plyometric, or “jump”, training is based on this fact). This basic function of the muscle spindle helps to maintain muscle tone and to protect the body from injury.

One of the reasons for holding a stretch for a prolonged period of time is that as you hold the muscle in a stretched position, the muscle spindle habituates (becomes accustomed to the new length) and reduces its signaling. Gradually, you can train your stretch receptors to allow greater lengthening of the muscles.

Some sources suggest that with extensive training, the stretch reflex of certain muscles can be controlled so that there is little or no reflex contraction in response to a sudden stretch. While this type of control provides the opportunity for the greatest gains in flexibility, it also provides the greatest risk of injury if used improperly. Only consummate professional athletes and dancers at the top of their sport (or art) are believed to actually possess this level of muscular control.

This clarified a lot for me.