Decayed organic matter is in the ground as well as soil and clay. Under pressure, the organic matter can change to oil. The crude oil seeps upward through fractures, or porous sedimentary rock layers. It may form a pool at the surface.
The lighter parts of the crude oil evaporate into the atmosphere. That leaves behind behind a black, sticky asphalt. Tar pits are often dug into because they contain many fossils.