The thing that becomes a fossil, such as a dinosaur or a trilobite or a hat, gets buried in amongst all the small bits of rock (silt, sand, gravel), and is compressed along with the mixture by the weight of water and multiple layers of similar material on top.