Here's why:
* Fossil: A fossil is any preserved remains or trace of a once-living organism.
* Mold Fossil: The cavity you're describing is a type of mold fossil. A mold fossil forms when the original organism decays, leaving a negative impression of its shape in the surrounding rock.
In the case of a shell, the shell itself would have dissolved or decomposed over time, leaving behind an empty space in the rock that reflects the shell's shape and structure. This empty space is the mold fossil.
Note: Sometimes, minerals can fill in the mold, creating a cast fossil that is a positive replica of the original shell.