Because they feel warm and safe. cats have few predators, but still prefer to sleep somewhere they cannot be seen. they use ambush tactics to hunting, and a box is a good place which to spring out. they also seek warmth and cardboard, a good insulator, feels nice and warm to sit on.