The reason I've read is that it's a leftover from when they lived in the wild, and it would help make sure they don't lay down on top of something dangerous, like a snake or ant colony. It would also make since to do it before pooping since they're going to be in a vulnerable position.