The answer in Genesis is that there were no stars when the earth was created. God didn’t make the stars until three days after he made the earth.
But in the book of Job, God has a different answer. Now he says he laid the earth’s foundation while the morning stars sang. So there were stars, then.
Possible explanation
Some of the planets are sometimes called “morning stars”. So you could interpret the verse in Job as referring to planets, not stars. (Not that anyone knew planets weren’t stars, back when the Bible was written.)