The short explanation is the hydrocarbons that produce oil and natural gas are abundant throughout the universe. A book was written about the subject titled "The Deep Hot Biosphere". The author is Thomas Gold. It was published in 1999.
Here is a link to a review:
The Deep Hot Biosphere The Myth Of Fossil Fuels
Here is an excerpt from the link:
"the book advances the stunning idea that most hydrocarbons on Earth are not the byproduct of biological debris ("fossil fuels"), but were a common constituent of the materials from which the earth itself was formed some 4.5 billion years ago
It was a fascinating read.
