The circling thing is a relic of domestic dogs' wild past, a bit of hard-wired behavior that hasn't been bred out yet. Biologists and dog experts say that it might just be a strange quirk for domestic pooches, but for wild dogs and wolves, circling before hunkering down for the night was practical and sometimes even life-saving.
Dogs' ancestors traveled in packs and slept out in the open. Doggie beds were a few thousand years away, so a good way to get comfortable sleeping on the ground was to tramp down some grass and vegetation to make a "bed." Walking around in a tight circle a few times would mat down tall grass to sleep on and also disturb and kick up any bugs or snakes that might be lying in the dog's chosen spot.
There might be a social element to circling, too. Wolves and wild dogs often travel in packs and have strict social hierarchies. When they bed for the night, they sleep in a tight circle to protect each other stay warm. Circling might be a way of marking one's sleeping space and establishing a spot in the circle, the canine equivalent of calling first bedsies.