Every muscle/tendon complex has receptors that feed back to the brain that limit range of motion in order to avoid injury to a muscle. As an example, an unconscious/asleep person will have a greater range of motion than someone that is awake. This is also the mechanism that makes your leg kick when the doctor whacks your knee with a hammer.
What stretching does, is progressively teach that feedback complex to accept a greater range of motion before limiting anything. (Barring actual physical structure limitations).
So essentially the brain monitors the feedback from these muscle/tendon complexes, and at a certain point it says "Whoa, stop there or we are going to get hurt". Stretching creates a different Whoa point, which in turn means you can go through a greater range of motion before that limit is hit. I.E., increased range of motion/mobility.