When, in a forest, the plants and animals die, then start decomposing. Over years, new layer gets deposited over them, new plant remains and new animal remains are added up. Those gets decomposed. Over a very long period of time those remains turn into crude form or carbon. Now, this is extracted from the earth and separated into various petroleum products like diesel, crude oil, petroleum.