The process of fossil formation is as follows: When living organisms die and they get buried in the sand, over the time, more and more sediment covers the remains.
Under tremendous pressure, water and other minerals seeps from the body of dead organisms and these spaces are filled by some other minerals which recrystallise.
In some cases, the imprints of hard parts such as bones, teeth are formed on the rocks due to great pressure.
Different types of fossils are:
mold fossils - fossilised impression made in the substances
trace fossils - formed of the parts such as eggs, nests, footprints, etc.
cast fossils - The mold gets filled in by some substance.