The formation of atoms in the nuclear reactions in stars involves some quite complex mechanisms. To get a proper answer you would really need to do quite a lot of reading.
A few short and simple answers: carbon in particular, and similar "light atoms" are produced in nuclear reactions in the core of stars. Only atoms with atomic number less than iron, or possibly nickel, can be made in this way. Heavier atoms are much less abundant, and are formed mainly (only?) in supernova explosions.
Atoms with even atomic number are more stable (lower energy) and more abundant than those with odd atomic number. Even number elements can have as many as 8 or 10 stable isotopes; odd number elements have only 1 or 2. Throughout the periodic table, the cosmic abundance of elements is, generally speaking, a zigzag line with peaks at even number elements and dips at odd number elements.
Carbon is formed in a catalytic cycle; it is effectively formed from 3 helium atoms, but the mechanism is much more complicated than 3 helium atoms coming together. Lithium, beryllium, and boron have much lower cosmic abundance than carbon, nitrogen, and oxygen, and only enter into the carbon production process in a very transitory way.
The nuclear processes that form elements heavier than helium are fairly well understood, but there is still some uncertainty -- it is enormously difficult to observe precisely what is happening in the core region of any star, even our own sun.
If you want to go deeper into this stuff, try:http://hyperphysics.phy-astr.gsu.edu/hbase/astro/astfus.htmlhttp://en.wikipedia.org/wiki/Star#Nuclear_fusion_reaction_pathwayshttp://www.astrophysicsspectator.com/topics/stars/Fusion.html