>>11929871do you mean how it's determined as in how we verify the structure of an existing compound? In which case you can use mass spec and NMR among other analytical techniques.
Or do you mean how are these hydrocarbons actually formed in nature?
In which case I'm not sure simply mixing elemental hydrogen and carbon would necessarily give you hydrocarbons. Most hydrocarbons in nature are formed from organic processes.
That said, I think they've found organic molecules in space too, although I'm not sure under what conditions they form. But alkenes/alkanes are mostly derived from crude oil which originates from organic life.