Time is not the needed factor. Fossils can form very quickly in the right circumstances, or theorically millions of years.
Fossils form when organic matter or evidence of life is preserved.
Animal prints in newly formed concrete is a fossil. The chemical reaction of the carbonate in the cement reacts quickly. I have a fossilized spark plug that was preserved in the basaltic rocks off the coast of Oregon. The rust from the spark plug combined with the Iron in the basalt fusing the spark plug to the surrounding rocks.
A fossil can be the actual material that is preserved such as a fly in amber. A fossil can be a mold where the original material has disappeared and has left an impression of the original shape.
A fossil can be where the original material is replace by stone such as fossilized wood, where even the grain of the wood is observable.
If there is enough carbonate ( natural cement) a fossil can form quickly. The organic material needs to be buried so that it is not destroyed by bacteria and other natural causes.