Intact shells are a limited resource in the rocky intertidal. Snails, of course, build and live in their shells for the duration of their lives. A snail's body is attached to its shell, so until it dies it is the sole proprietor of the shell. Once the snail dies, though, its shell goes on the market to whoever manages to claim it. Empty shells tend not to hang around for long.
Hermit crabs also live inside snail shells. They are the ones that compete for empty shells to become available. Here in California, at least, the hermit crabs can't kill snails for their shells; they have to wait for a snail to die. And once a shell comes on the market, it will have a taker even if it's not the ideal size for the crab. It's not at all uncommon to see hermit crabs that can fit only their abdomen into the shell, leaving the head and legs exposed and vulnerable. On the other end of the spectrum, many hermit crabs are so small that they can pull into the shell and not be seen by an inquisitive tidepool visitor. Anybody taking a snail shell home as a souvenir—where such takes are allowed, of course—must be certain that there is no tiny hermit crab hiding deep in the depths.
From a hermit crab's perspective, the best shell is one that is big enough to retreat into but light enough to be carried around. Snail shells come in a variety of shapes and corresponding internal volumes. Turban snails, with their roughly spherical shape, have a large interior space and are coveted by larger hermit crabs. For example, the grainy hand hermit crab (Pagurus granosimanus) seems to really like both black and brown turban snail shells.
Original inhabitant and builder of the shell:
And opportunistic second inhabitant of the same type of shell:
Other snails are not even remotely spherical. Olivella biplicata, for example, is shaped like the pit of an olive. Unlike Tegula, of which both intertidal species are found in rocky areas, O. biplicata burrows in sand. Note the shape and habitat of this olive snail:
These olive snails have a smaller internal volume, and thus tend to house smaller hermit crabs. Young individuals of P. granosimanus can be found in olive snail shells, but they quickly outgrow the cramped quarters and need to find a larger home. Smaller hermits such as Pagurus hirsutiusculus, though, are often found in olive shells.
Any hermit crab that finds itself robbed of its snail shell has a short life expectancy. The front end of the hermit resembles the front end of any crab, with the familiar armored legs, claws, eyestalks, and antennae. But the abdomen is soft and unarmored, covered by only a thin cuticle. The abdomen is coiled to follow the coiling of the snail shell, which allows the crab's body to curl around the columella, the central axis around which the shell spirals. In this way the crab can hang onto its snail shell and resist a tug by a would-be predator. A strong enough tug, though, will rip the crab's front end (head + thorax) away from its abdomen. So if you ever find yourself with a hermit crab in hand, do not be tempted to remove it from its shell by yanking it out!
The next time you encounter gastropod shells in the tidepools and want to know whether the inhabitant is a snail or a hermit crab, watch to see how it moves. Hermit crabs scuttle, as crabs do, while snails glide along very slowly. You would also notice a difference as you pick up the shell: snails stick to the rock with their foot, which you will feel as a suction. Hermit crabs don't stick at all, so if the shell comes away easily it likely houses a crab instead of a snail. See? Easy peasy lemon squeezy!