A Matter of Warmth
Puppies are an altricial species, meaning that, when they are born, they are born in a pretty much immature state. This means that unlike precocial species such as foals, calves and fawns, puppies are unable to walk when they are born and they depend to a great extent on their mothers during their first weeks of life.
When puppies are born, and during the first two weeks of life, puppies are unable to eliminate on their own (mother dog must lick their bottoms to stimulate them to eliminate) and they are not fully mobile, meaning that they must sort of crawl if they need to move from place to place.
On top of this, newborn puppies are unable to regulate their core body temperatures. They therefore depend on the warmth of their mother and litter mates in order to stay warm. Indeed, according to research conducted by Yngve Zotterman, of the Swedish Research Council, puppies come equipped with special "heat sensors" in their noses which helps them find their way towards their mom and siblings in case they get separated and risk being chilled.
When puppies are born, their temperature is around 97°F, but then as the puppies develop, they reach the “normal” 101°F at around three weeks of age. Prior to this time, breeders will usually rely on some type of heating source (heat lamp, heating pad) to ensure the puppies do not get chilled. At the same time though, breeders must be careful that the area doesn't get too warm which can also be problematic.
During the neonatal stage, it is therefore possible for puppies to pile up on each other if they are feeling cold. This is an instinctive behavior. Just as with raising baby chicks, you may therefore want to take steps in making the area less chilly if you notice young puppies crowding over one another in piles just like baby chicks huddling together when cold.
Puppies are Social Beings
Once puppies are past the stage during which they depend on one another to keep warm, they still may instinctively seek out each other and sleep in piles. The reason for this at this time is likely because dogs are social beings and seek out each others' company.
It feels reassuring to puppies to stick together. According to Scott and Fuller (1965), by 7 weeks, although competitiveness among siblings prevails, bonding remains strong. This can be easily noticed upon witnessing the distress vocalizations in 7-week old puppies when isolated even briefly from their litter mates at this time.
This attachment is expected to decline by 10 weeks of age. However, puppies may still sleep in contact with each other if this helps them feel warm and reassured.
"Each pup serves as a social presence for its litter mates and obtains social comfort for itself by huddling close enough to the other young pups in the brood so that it can feel their touch. If all the puppies in the group try to crowd together to feel the comforting presence of one another, the result is a pile of puppies." Stanley Coren, Do Dogs Dream?: Nearly Everything Your Dog Wants You to Know