Heres further discussion about how some of the characters comesto be in his mind and the roles they play
Moving on to the characters closer to him, Ash's traveling partners are aspects of himself that he can enjoy, but doesn't like to associate with himself. Brock is Ash's repressed sexuality. Ash fell into the coma a virgin and needed an outlet for his growing sexual frustrations. Since he can never experience sex, Brock must never succeed. But Brock isn't just a projection of Ash's sexuality, he is also a projection of Ash's fatherly instincts. Brock leaves his siblings to journey with Ash because Ash can't cope with having that much responsibility at his age. Brock's stay with professor Ivy was an attempt to outright suppress his sexuality. You may notice that James got much more dialogue in this part of the series, as well as getting more touchy-feely with his Pokemon and exposing most of his backstory. Ash didn't enjoy this much, which is why Brock comes back horrified and refuses to speak about it (Ash's subconscious was repressing him at the time, so other than a general feeling of dread, he has no idea of what happened). Further evidence of Brock being Ash's sexuality is that he keeps returning to the series after Ash meets a new girl aspect of himself.
Misty is the first such aspect we encounter. Because she is the first and because she is merely an aspect of Ash are explanations for why Misty plays so prominently in the show but is ultimately unattainable (because he never really knew her before the coma). Since Misty is his initial love interest - if only subconsciously - he needed her to reach a certain level of womanhood. He felt that people could only have relationships after they've matured. In practice, though, he finds that he can't cope with it (lacking the real-world experience) and wants the normal pushy, arrogant Misty he knew, thus not letting her keep Togepi. We can see this arc in the constant berating of his sexuality (Brock), but her eventual mellowing until she had faded into the background. Since Ash was quite attached to her, this was traumatizing and after this experience, anyone around him "threatening" to mature quickly ends up leaving for another, more naive fill-in.
Gary Oak is what Ash wants to be. He is wish fulfillment. He succeeded, and then settled down to a normal life. Ash needs someone to succeed in his world or he won't be able to validate it and will start questioning why he is where he is. It's a subconscious trap to keep him from becoming too aware of his situation. His mind must have figured out that awareness of the coma would snap him out of it, but it would cause brain damage, so it took something the boy already loved and built a way out for him with it. However, Ash is too complacent to make a final stand and fight his way out of it, and so cannot escape. This is why he keeps encountering Legendary Pokemon. They're his mind's way of showing him he can do great things if he tries, and it's a way to encourage him to push forwards.