It's all in your brain.
Scientists have found that dogs across a variety of breeds align their body axis with the Earth's magnetic field before squatting to poop. "Our analysis of the raw data ... indicates that dogs not only prefer north-south direction, but at the same time they also avoid east-west direction. It is unclear why the dogs find the planet's north-south axis more comforting."