When an animal or plant dies in a muddy environment, the soft tissue will start to decompose which leaves behind hard bones/shells. Over time the sediment will build over the top and it will harden into a rock still showing the bones.