A scientific experiment gone wrong could also be a cause. Maybe a scientist was working on a gene - editing experiment and something unexpected happened. The boy's DNA could have been altered in a way that made his body develop female characteristics. Another reason could be a curse. In some fictional stories, an angry witch or wizard might put a curse on a boy which results in his transformation into a girl.
Magic could be a reason. Just like in fairy tales, a magical spell or a magical object can cause such a transformation. For example, a magic wand waved by a mischievous fairy might accidentally turn a boy into a girl.
In some stories, it could be due to a wish made by the boy himself. He might have wished on a magic star or in a magical place to experience life as a girl, not really thinking it would come true. And then, some supernatural force made it happen. Also, there could be a strange phenomenon in a particular place, like a portal to a different dimension where the rules of gender are different, and passing through it changes the boy into a girl.