Yawning crocodiles:
I'd guess stretching evolved as an elaboration on yawning, maybe as tetrapods became more active and flexible and put higher demands on the rest of their skeletal muscles beyond their jaw muscles. In newts and salamanders, the jaw muscles are the only ones that need to deal with prolonged and intense exertion; they often clamp down on a large worm and spend 30-60 minutes slowly eating it, exerting continuous pressure on it with their jaws to hold onto it and periodically shaking their head from side to side to keep the worm from burrowing into the soil while they gradually swallow more and more of it. If they get exhausted before they're done, the worm escapes. With the albino axolotls, the jaw muscles become visibly pink from the increased blood supply to them when they're wrestling a worm.
All the other muscles have quite modest demands placed on them, and don't need to function for long periods or at high intensities. Locomotion in newts and salamanders is characterised by very frequent resting; they might walk or swim for a few seconds or a few tens of seconds and then rest for at least as long, and they don't keep it up for very long even with the frequent breaks.
They're also not all that flexible; they can't lick their own cloacae like dogs and cats and they don't have much dynamic range to their movements. Their bodies are kind of intermediate in flexibility between fish and mammals.