1. Mineralization: This is the most common way fossils form. When an organism dies and is buried by sediment (like mud or sand), minerals in the sediment can replace the organic material in the organism's bones or other hard parts. Over time, these minerals will harden and become rock, preserving the shape of the original organism.
2. Mold and cast: Sometimes, instead of being mineralized, a fossil can leave behind a mold and a cast. If an organism's remains are buried in fine sediment that hardens around it, it can create a mold of the organism's shape. If the mold is then filled with sediment or minerals that harden, it creates a cast that preserves the shape of the original organism.
3. Compression: Some fossils are formed when an organism's soft tissues are compressed and flattened, leaving behind an imprint. This can happen if an organism is buried quickly and completely, so that there's no oxygen to allow decay.
There are many other ways that fossils can form, including freezing, drying, and even getting stuck in tree resin (which can eventually become amber). However, the three examples above are the most common ways that fossils form.