Why do cats like boxes? It is not so much that cats like boxes but they prefer small places to curl up. This is an instinctual behavior. While cats are very good hunters in the wild they are also hunted by larger predators. Eagles, hawks, owls, wolves, foxes and coyotes have all been known to prey upon cats.
A cat that is curled up in a small area like a box is not only hiding but is protecting their underbelly from attack. In addition, by sleeping curled up, a cat already has his legs under him so it is easier to spring into action for fight or flight. Finally, curling up helps conserve body heat in cold environments.
Taking shelter in a small confined area also makes it easier to watch for predators. This is especially true if the small space is higher up in a tree or other tall location. In addition a cat curled up in a small space makes it more difficult for predators on the ground to enter and attack. Cats will only sleep sprawled out if they feel safe in their environment. Keep in mind that cats will also sleep curled up even if they do feel safe as it is a sleeping position that is quite comfortable and natural to a cat. So seeing your cat curled up in the home in a box or a bowl does not mean they feel unsafe. It is simply the most comfortable position.