Universe started as a Big Bang.
Just after the Big Bang, only Hydrogen and Helium were formed.
All the other elements (including Carbon and Oxygen) which exist today were formed later on by nuclear fusion inside stars. The ashes of these stars were dispersed in the universe which took part in the formation of planets and later on - Life.
For a simplified summary of the chain of events which led to the formation of the Universe as we see today, read my previous post.
Follow me for being with me on a wonderful journey through the untrodden paths of the physics,the metaphysics and the philosophy of life.