I've always thought that they do it because it's more cozy and warm for them. I don't have a scientific explanation, though. I'm not entirely sure that anyone does. One cat that I had for many years used to sleep sitting up with his back propped against the sofa or a pillow much of the time. One of the cats that I have now sleeps on his back with his hind legs spread out. Who knows. I guess they're not much different than us. They just sleep in whatever position is the most comfortable for them.