When animals, plants and other organisms die, they typically decay completely. But sometimes, when the conditions are just right, they are preserved as fossils.

Several different physical and chemical processes create fossils, according to the New York State Geological Survey.

Freezing, drying and encasement, such as in tar or resin, can create whole-body fossils that preserve bodily tissues. These fossils represent the organisms as they were when living, but they're very rare.

Most organisms become fossils when they're changed through various other means.

The heat and pressure from being buried in sediment can sometimes cause the tissues of organisms — including plant leaves and the soft body parts of fish, reptiles and marine invertebrates — to release hydrogen and oxygen, leaving behind a residue of carbon.

This process — which is called carbonization, or distillation — yields a detailed carbon impression of the dead organism in sedimentary rock.

The most common method of fossilization is called permineralization, or petrification. After an organism's soft tissues decay in sediment, the hard parts — particularly the bones — are left behind.

Water seeps into the remains, and minerals dissolved in the water seep into the spaces within the remains, where they form crystals. These crystallized minerals cause the remains to harden along with the encasing sedimentary rock.

In another fossilization process, called replacement, the minerals in groundwater replace the minerals that make up the bodily remains after the water completely dissolves the original hard parts of the organism.

Fossils also form from molds and casts. If an organism completely dissolves in sedimentary rock, it can leave an impression of its exterior in the rock, called an external mold. If that mold gets filled with other minerals, it becomes a cast.

An internal mold forms when sediments or minerals fill the internal cavity of an organism, such as a shell or skull, and the remains dissolve.

A dead dinosaur lies partially in a stream. Fossilization only happens in the rarest of cases, when a plant or animal dies in the right circumstances. Animal corpses are usually eaten by something, or bacteria rots them away before fossilization can occur, and even hard parts like bones and shells are eventually destroyed through erosion and corrosion. The trick to becoming a fossil is to die in a location where your body - or bits of it - are protected from scavengers and the elements. This means getting buried in sand, soil or mud and the best place for that is on the seabed or a river bed. The bones of a dinosaur buried beneath a hill. Only in very rare cases do the soft parts of animals - the flesh, skin and internal organs - become fossils. Even when buried under mud or soil, decay still takes place, though lack of oxygen does slow it down.

 If a skeleton is dug up at this stage, it will still be made of bone. Remains like these that haven't truly fossilised yet are sometimes called 'sub-fossils'. The bones of a dinosaur get buried more deeply and begin to change chemically as layers of sediment accumulate on top of them. As more time passes, sub-fossils become buried deeper and deeper. What was mud or sand becomes compressed on its way to becoming rock. But even safely sealed away underground, time doesn't stand still. Chemicals and minerals percolate through the sediment and the original bone or shell gradually recrystallizes. In extreme cases, the entire thing can dissolve away, leaving a hollow where it once was. If paleontologists find a hollow like this, they can pour liquid rubber in to make a fossil cast, or put it in a medical scanner to see what the original looked like. 

The bones of a dinosaur are buried deep enough and long enough to fossilize. In other cases, minerals from the rocks gradually impregnate the bone, shell or wood, changing its chemical composition and making it capable of surviving for as long as - or sometimes longer than - the rock enclosing it. In cases where the original has dissolved away, the minerals can gradually fill the hollow to create a natural cast of the original. So sometimes a fossil doesn't contain anything of the original creature except its shape. Even that shape can take a battering! If the rocks are distorted and squeezed by geological forces, then the fossils within them will be too. The fossil bones of a dinosaur appear in the soil as the rock enclosing them erodes away. Even rocks have a finite lifespan. Eventually the rock enclosing a fossil is eroded away, and the fossil is revealed on the surface of the ground. With luck, a sharp-eyed fossil collector will spot and excavate it. Otherwise the elements will continue to batter it, until it - along with the rocks around it - is reduced once more to sand, silt or mud.