This point is grossly under-appreciated. Hydrocarbons have also been detected in comets which dates the compounds to before the formation of the solar system.
The chemistry is pretty simple. Take something with carbon in it. Take some more stuff with hydrogen in it. Mix it all up and toss in some iron.
Heat it up to a couple thousand degrees and squeeze the bejeepers out of it.
Voila! More hydrocarbons than you can shake a stick at!