Short answer: Due to habituation. You do something enough number of times, then that event ceases to be something new, and your body adapts to it.
In this case, you train your body to accept more risks allowing greater lengthening, before it begins to internally signal the muscles that an injury is incoming.
Read below for the slightly longer version:
The stretching of a muscle fiber begins with the sarcomere, the basic unit of contraction in the muscle fiber. As the sarcomere contracts, the area of overlap between the thick and thin myofilaments increases. As it stretches, this area of overlap decreases, allowing the muscle fiber to elongate. Once the muscle fiber is at its maximum resting length (all the sarcomeres are fully stretched), additional stretching places force on the surrounding connective tissue.
There are two kinds of muscle fibers: intrafusal muscle fibers and extrafusal muscle fibers. Extrafusil fibers are the ones that contain myofibrils. Intrafusal fibers are also called muscle spindles and lie parallel to the extrafusal fibers and are the primary proprioceptors in the muscle.
When the muscle is stretched, so is the muscle spindle. 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 the myotatic 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.
You can read more about it (including the role of the lengthening reaction by the gogli tendon organs) here: http://people.bath.ac.uk/masrjb/Stretch/stretching_2.html#SEC13
It has also been published in a short section in this paper. I am sure you can follow the reference chain if you need to.
Smith, Craig A. "The warm-up procedure: to stretch or not to stretch. A brief review." Journal of Orthopaedic & Sports Physical Therapy 19.1 (1994): 12-17.