Sedimentary rock formation:
Fossils form in many ways but the common method begins with the death of animals or plants in watery environment. These creatures gets buried and decompose quickly leaving the remnants of their bodies such as shells and bones behind.
Overtime deposition of material occurs and sedimentation buries the shells and bones, and they further become part of the hardened rock. Erosion and weathering of rocks later reveals this hidden secrets of ancient times. There are five ways in which fossils can form permineralization, natural casts, etc.