“If Adam and Eve had Cain and Abel, shouldn’t those be the only people on earth? Because when Cain kills Abel, Cain is scared that someone will kill him. But at that time, no one else existed. So who was Cain’s wife?”
Okay, well, let’s start by acknowledging that the Bible doesn’t give us explicit answers to many of our technical questions about the early days of the human race, especially in areas of study that are not spiritually significant. So we cannot say with any biblical authority how Cain got his wife. No Bible student can.
That said, let’s not imagine that either the human writer of Genesis or those who told the story for centuries before him were unintelligent men and women. They were not.