My name isXXXXX am an exercise physiology expert and fitness expert.
To answer you question, there are 2 types of stretching and basically 2 purposes to each. This is a little longer of an answer and I will try to put it into terms that are easy to visualize.
The reason muscles cramp is because of the build up of waste product(lactic acid) and the nonstop firing of the motorunit. Basically this is called tetanus. It can be helped by stretching which physically lengthens the muscle and reduces the active tension on it. Conditioning is the other part, but obviously like performance increases this part takes time.
Static stretching, which is stretching and holding for 20-30 second holds is the type that can be done before but should after your workouts to allow the muscles and tissues to relax and release tension. This longer stretching actually reduces performance as it really does allow them to relax, so you can see why this is better AFTER working out - when you are recovering. Static stretching IS fine, before - but people doing max effort activities like olympic throws, weightlifting and powerlifting may not always want to.
Dynamic and contract release(PNF- proprioceptive neuromuscular facilitation) stretching is the type where you put the hamstring(in this example) at a light length, then contract the muscle at that length for 6 seconds at length, then attempt to further the stretch for 10 seconds, when you reach a new length contract for 6 etc..repeat 3 times. So this would be good for max effort, as it only reduces the inhibition as opposed to relaxing the muscles.
Muscles act as a pump for waste products, so when they are inflexible, the amount of work to move a body becomes more. Imagine having to take baby steps to walk as opposed to long strides, its more effort. In cases where someone lacks flexibility, if muscles are too tight, there isn't really enough "time" for them to relax to allow that muscle pump to work. So as you run, waste is produced, but each step allows that waste to be removed. During the ON phase of your interval running you are producing much more waste than the OFF phase which is why you feel it in your calves, quads and hamstrings. This is why inflexible inactive people tend to cramp much faster - aside from the fact that their "removal" systems aren't yet upregulated
So in your case during your running, the leg swinging through to the front is the relative "relax" phase, the contraction to hold you up and propel you is the active phase when that pumping mechanism works.
So ideally your routine would be, light conversational jogging for say 5-10 minutes to get warm, PNF stretching or light static stretching, then your workout whatever it is: interval training, fartlek training, long run, tempo run, weight training etc.. THEN when you are finished, do your cooldown THEN do your static stretching.
Muscles always want to shorten, same with all tissues, its that much less energy required for the body to move shorter distances and swing less swings of a limb.
So to answer, do your static stretching for 2-3 sets of 20-30 seconds each stretch after your workout, but if it helps to loosen you up static is perfectly fine before. I personally like static stretching all day whenever I can, but I am very inflexible if i don't stay up on it.