Most fossils are formed when organisms or their traces are buried by sediment.
Layers of sediment, such as sand and silt, cover the remains of the organism or its trace.
Eventually the layers may harden into sedimentary rock, trapping the remains inside.