The answer is: in preschool, children have compatible interests with members of the same gender. Later, peer pressure may motivate their preference for same-gender peers.
This happen because before people reach puberty, most children still haven't been introduced to the concept of social status.
As people enter puberty, people already aware of the social status around us which make us more likely to avoid doing things that might damage/hurt our social status.
The need to maintain this social status, can create some sort of pressure to ourselves that make us often disregard out own preference and choosing to pursue somethings that can increase our social status. This could include a wide variety of things, such as our preference for same-gender peers, our fashion sense, our preference of hobbies, etc.