Radiometric dating geologic time and the age of the earth
However, note that because of the "principle of cross-cutting relationships", careful examination of the contact between the cave infill and the surrounding rock will reveal the true relative age relationships, as will the "principle of inclusion" if fragments of the surrounding rock are found within the infill.
Cave deposits also often have distinctive structures of their own (e.g., spelothems like stalactites and stalagmites), so it is not likely that someone could mistake them for a successional sequence of rock units. Each of them is a testable hypothesis about the relationships between rock units and their characteristics.
Many other indicators are commonly present, including ones that can even tell you the angle of the depositional surface at the time ("geopetal structures"), "assuming" that gravity was "down" at the time, which isn't much of an assumption :-).
In more complicated situations, like in a mountain belt, there are often faults, folds, and other structural complications that have deformed and "chopped up" the original stratigraphy.
They are the "initial working hypotheses" to be tested further by data.
Using these principles, it is possible to construct an interpretation of the sequence of events for any geological situation, even on other planets (e.g., a crater impact can cut into an older, pre-existing surface, or craters may overlap, revealing their relative ages).
Most of these principles were formally proposed by Nicolaus Steno (Niels Steensen, Danish), in 1669, although some have an even older heritage that extends as far back as the authors of the Bible.
A few principles were recognized and specified later.
For example, wave ripples have their pointed crests on the "up" side, and more rounded troughs on the "down" side.
Despite this, the "principle of cross cutting relationships" can be used to determine the sequence of deposition, folds, and faults based on their intersections -- if folds and faults deform or cut across the sedimentary layers and surfaces, then they obviously came after deposition of the sediments.
You can't deform a structure (e.g., bedding) that is not there yet!
There are situations where it potentially fails -- for example, in cave deposits.
In this situation, the cave contents are younger than both the bedrock below the cave and the suspended roof above.