The riddle
What Runs Around the Yard Without Moving?
Two ways to run
Wiktionary lists run as moving swiftly and, in a separate intransitive sense, extending in space or through a range. A fence runs in the second sense: its line extends along the edge of the yard. Wikipedia describes a fence as a structure that encloses an area, usually built from posts joined by boards, wire, rails or netting. Unlike a wall, it has no solid foundation along its whole length. Nothing about it travels, which is the whole contradiction in the question. The riddle is also told about a house or a field, and the same answer holds.
Short for defense
Wiktionary traces fence to Middle English fens, short for defens, the act of defending, and dates the meaning of an enclosure to the mid 15th century. The older English word for it was hege, which lives on as hedge. So the word fence began as a short form of defence.
A yard that began as a fence
The yard in the question is an old word too. Wiktionary says it comes from Old English ġeard, which meant yard, garden, fence and enclosure all at once, and it is related to the word garden. The oldest sense of the place already included the thing that surrounds it.
One yard becomes two
Edith B. Ordway's 1915 collection has this question: "What is the difference between one yard and two yards?" and answers, "A fence." It works because a fence put across one yard leaves two.