The way in which celestial bodies are formed, according to scientific research and studies is that material collects in space and form them, like particles. The Christian belief is that God created them from scratch, however. Other religions and beliefs differ as well.
But, according to scientific theories, which are simply educated guesses, celestial bodies were formed by the Big Bang Theory which says that the first stars were birthed within clouds and consisted of the two lightest elements, hydrogen and helium that occured, according to the theory, over 13 billion years ago. The reason they are not planets is because there wasn't any carbon, oxygen, silicon, iron nor were there any other metals in which to form the planets with.