An invertebrate with a hard shell is buried in soft sediment. If the dead organism is left undisturbed, the sediment around it will compact. The soft parts of the organism will rot away and the hard exoskeleton will remain unchanged for thousands of years.
With vertebrates and organic substances like wood permineralization occurs. A porous substance like bone is buried in sediment. Water seeps through the pores. Minerals in the water are left behind in the pores. Over time, the bone dissolves but the minerals remain and take the shape of the bone. The bone in like a mould for the minerals to take on its shape.
With organisms such as ammonites, the process again begins by being buried in sediment. Water seeps through the organism, dissolving some of the hard parts and replacing the lost parts with minerals. The original parts of the fossil have been replaced by minerals.
A plant gets covered in sediment. The carbohydrates in the plants decay and leave behind a carbon residue, like a fingerprint of the organisms structure.
With organisms that have shells or skeletons, a fossil is made by an impression in soft sediment/mud. Over time, the organism dissolves and the sediment compacts and hardens, leaving a cast or a mold of the organism.
Trace is a fossilized impression of an organisms movement, for example footprints. The sediment must harden before it is washed away. Softer sediment laid on top will protect the trace from erosion.
A low oxygen environment(anaerobic) is necessary for preservation. Organisms and the softer parts can also be preserved in amber, peat, and ice intact.
Conditions that favour fossilization