Because they are hard-wired to do it. Coming from ancient times when dogs traveled outside in packs, they would do this for both comfort and safety. There may have been insects or snakes to scare off before lying down. The walking around action would make their spot more comfortable to lie down on.
Some scientists believe domestic dogs no longer need to do this and that eventually the behavior will be bred out. Nanny is not so sure. Dogs will still lie down outdoors where they may encounter the same risks and, of course, they will want to make their sleeping spot comfortable.