The remains of ancient humans, animal or plant traces, are called fossils. Fossils take thousands, and sometimes millions, of years to form.
Not all remains become fossils. Fossils are rare. Most animals and plants decompose after they die and can become fossils if the remains are covered with sand, mud, or flames.
Hard bones survive, and other parts of animals or humans rot.
Layers of soil, etc., are formed on top of the skeleton.
As more and more layers are formed, the pressure on the lower layers increases and they turn into sedimentary rock.
The skeleton dissolves as water passes through it. This leaves a gap the same size as the skeleton in the layers of the rock.
Water minerals fill the gap left by the skeleton to replicate the original bone.
Most of the fossils are from marine animals, as the ocean floor is the ideal place for layers of sediment to build up on top of a dead animal.
picture https://pixabay.com/photos/fossil-petrification-stone-fish-514980/