Your tendons in your leg are being stretched out farther than they should be. The shaking is your body's way in telling you that it is being stretched too far.
This sounds as if it is related to the muscles which have become tense during long spells of inactivity. It's nothing to be concerned about if it does not hurt.
Every time you stretch, you are pulling your muscles, tendons and ligaments. They are like elastic bands and rubber on a very cold day, when you stretch them out sometimes.
While stretching you must have good position, balance and concentration. Any wrong movement or imbalanc or excess pressure on either of legs, muscle pain, sprain in leg could be the reasons.