Why do dogs often walk in circles before lying down for bed? Turns out, it's a survival trait inherited from their evolutionary ancestor the wolf. From Southern Living:
“Turning in circles before lying down is an act of self-preservation in that the dog may innately know that he needs to position himself in a certain way to ward off an attack in the wild,” notes [veterinarian and Animal Center co-owner Lynn] Buzhardt. “Turning around 360 degrees also provides an opportunity to take one last look for potential predators before bedtime.” [...]
In addition to self-protection, circling and nesting help dogs in the wild to make their sleeping space more comfortable. Undomesticated dogs don’t know the luxury of fluffy pillow and plush cushions—to make a “bed,” they mat down grass, clear away rocks and branches, and reposition brush. This practice helps dogs uncover any hidden threats like snakes or other critters, and it also allows them create a nice sleeping niche.