This can be because they were quickly covered by volcanic ash, or layers of fine clay, preserving the details.
These footprints were most likely made by Australopithecus afarensis, an early human whose fossils were found in the same sediment layer.
They were found at Laetoli in Tanzania.
Looking at much older rocks, footprints of dinosaurs can be used to find out all sorts of things about their lives.
There are plenty of dinosaur tracks in Texas, for example.
Dinosaur footprints can make an interesting educational activity.