Cramps are common. A muscle cramp is a involuntary contraction of a musle, especailly common of the legs and feet. Most commonly caused by hyperexcitability of the nerves that stimulate the muscles. Can also be the result of an injury and vigorous activity. Dehydration and electrolyte, element imbalances can also be causative factors. Simple stretching lengthens the muscle and stops the contraction.
Several causes. Cramping occurs when the muscles are irritated. The causes include venous disease, prolonged standing/working on legs, dehydration, heavy exercise, low levels of potassium, calcium, magnesium. Stretching will relax the muscles, which is the opposite of cramps where the muscles contract and ball up.
Many things. As dr. Isobe said, there are many things that can be a possible cause for leg cramps, including venous insufficiency. We honestly don't really know why stretching helps but it proably has something to do with resetting stretch mechanisms that are built into muscle fibers.