The fact is, stone masonry is a living, moving form of construction, if done correctly. In these days of hard reinforced concrete and very strong mortars that are used to create walls that try to resist the forces of nature by brute force, it is easy to forget that the enduring stone structures of old were held together by working with nature. The skilled masons worked with the force of gravity, and how it would interact with frost and thaw and any number of forces pushing on the walls, to create lasting structures.
Understanding Drystack Masonry
Drystack stonework is a great way to understand the forces in masonry. The reason, of course, is that drystack relies entirely on the force of gravity to stand. In a nutshell, gravity always pushes down. However, if the masonry is tilting or sloped, gravity will tend to shove the rocks down the slope. The stones may look stable, but the shifting of freeze/thaw cycles will over time provide the gentle shove needed to allow gravity to finish its work of moving the stones.

Retaining walls have an additional force to reckon with: the force of the material being retained. Freeze/thaw cycles are particularly active in soil, and can easily push over a wall and need to be accounted for.
Always Leaning
The way forces are combated in masonry is almost never done by building a perfectly straight wall. Rather, deliberate tilts and leans are built in. For instance, retaining walls lean into the fill, pushing it back into its place once the frost thaws. Even regular walls are often built of essentially two faces leaning into the core of the wall in the middle. The idea is, if you work with gravity, gravity will help hold the wall together. Thus, if the wall leans into itself, gravity will bind it firmly together.

But what if one wants a plumb face on the wall? The answer is to use the natural slope of the stones. Rare is the stone that is truly flat, so, if one puts the slightly thicker face on the outside of the wall, and the thinner on the inside, a gentle lean is formed. By stacking stones like this, with an occasional one put in backwards to keep the lean from becoming too excessive, the force of gravity will tend to push the wall inwards, into the fill for a retaining wall or into the core for a three-leaf wall, all the while keeping the outside face plumb.
Mortared Masonry
Good mortared masonry with a lime-based mortar should be built like its mortarless counterpart. Granted, the mortar makes the wall more forgiving to build, but mortar does decay and, more to the point, a good lime mortar is elastic and flexible, allowing the wall to shift and still live, without binding it into a monolithic mass that can eventually break. Thus, the mortar does not hold the stones in place despite gravity; rather, the mortar helps equalize pressure on each stone for greater strength and, as a bonus, helps the wall withstand the occasional impact. Gravity still does its work.