Fossils may be defined as the remains of the organisms which have been preserved in the form of molds or cast in rocks etc. since prehistoric ages.
When a plant or an animals dies, their remains falls on the ground. Over a period of time their body gets covered by sediments brought by rivers, winds etc. These sediments keeps on getting accumulated for over hundred of years and when that land gets eroded, the fossils can be seen clearly. Thus, the process of accumulation of dead remains of plants and animals for over hundreds of years results in the formation of fossils.
There are two components to this estimation of age of fossils.
Relative- If we dig into the earth and start finding fossils, it is reasonable to suppose that the fossils we find closer to the surface are more recent than the fossils we find in deeper layers.
Dating fossils- detecting the ratios of different isotopes of the same element in the fossil material.