Quora User is spot on! Methane doesn't stick around for long on Earth because all of the oxygen in our atmosphere reacts with it quite quickly. But in the absence of oxygen, methane can persist for millennia. read more
These hydrocarbons are called Tholin and are formed by the action of ultraviolet light and the solar wind on methane, nitrogen and other smaller carbon compounds. read more
This means a planet needs life to have oil. However, other organic compounds and hydrocarbons such as methane, ethane, and propane can form naturly without life. Titan, a moon of Saturn, has lakes of this stuff, but not true oil. There is a competing proposal that oil and coal form from primordial carbon naturally present on a planet. read more