Well, sometimes it's a test of character. The magic might turn a person into a girl to see how they would handle different situations and emotions. It could also be part of a grander plan by a powerful magic - user. They might want to use the transformed person to achieve a certain goal, like infiltrating a group that only accepts girls. And in some stories, it could be a way for the character to gain a new understanding of the world and those around them, so the magic makes this transformation happen.
One possible reason could be as a form of punishment. For example, if a character has been misbehaving in a way that is considered inappropriate for their gender, magic might transform them to teach them a lesson. Another reason could be an accident. Maybe a young wizard was practicing a spell and it went wrong, resulting in the transformation. Or it could be a magical curse placed on someone because of a feud between families or kingdoms.
In many stories, it can be a result of meddling with forbidden magic. If a character ventures into an area of magic that they are not supposed to touch, like a magic well that has specific rules, they might be turned into a girl. Also, it could be a reward in a strange way. For instance, if a character has shown great kindness towards a female - centered magic entity, the entity might turn the character into a girl as a way to let them experience life from a different perspective, which could lead to personal growth and new relationships.
In some turned into a girl stories, it could be due to a curse. For example, if someone offended an old witch or a powerful spirit, they might be cursed to change into a girl. Also, there could be a strange natural phenomenon. Like in a place full of strange energy, a person could be transformed into a girl just by being there for a while.
Magic gone wrong is a common reason. Just like a magician who miscalculates a spell and accidentally turns someone into a baby boy. Another reason could be a curse. For example, if someone angers an evil witch, she might put a curse on that person to turn them into a baby boy as a form of punishment.
Magic could be one reason. Like in a fairy - tale world, a magic spell might be cast on the boy. Another reason could be a scientific experiment gone wrong. Maybe some sort of genetic - altering experiment that was supposed to do something else but instead turned the boy into a girl.
Some kind of scientific experiment error. For example, if there was research on hormonal or genetic manipulation and something went wrong during the process.
One possible reason could be a magical curse. Maybe she offended a powerful sea witch who then turned her into a mermaid as punishment. Another reason could be a strange accident involving some sort of enchanted water. For example, if she drank from a forbidden pool in an old, magical forest that was somehow connected to the sea. Or it could be a result of a selfless act. Perhaps she saved a mermaid's life and in return, the mermaid magic transformed her into one of their kind to join their underwater world.
Well, in a story, the friend might be playing a prank with some new technology they don't fully understand. There are some fictional technologies that can manipulate the body's physical form. Also, the friend could be under the influence of a curse or a hex that causes them to involuntarily turn others into different genders. It could also be that the friend is exploring some sort of spiritual or esoteric practice and makes a mistake during a ritual that results in the transformation. For instance, if they are trying to communicate with a gender - changing spirit and things go awry.
A scientific experiment gone wrong. If he was in a science - fiction type of setting, perhaps some crazy scientist was testing a new device or formula that had unexpected side effects of gender transformation.
In some stories, it could be due to a magic spell. Just like in fairy tales, a wicked witch or an inexperienced wizard might accidentally cast a spell that changes a person's gender. Another reason could be a scientific experiment. Scientists might be trying to do something revolutionary like gender transformation through some new technology, but things go wrong and a male turns into a girl.
One reason could be a jutsu gone wrong. Maybe an enemy uses a forbidden jutsu on Sasuke that has an unexpected side effect of changing his gender.
It could be a scientific experiment. Scientists might be testing a new technology or drug that has unforeseen side effects, causing the transformation. This could then lead to a story about Otto Rocket trying to reverse the process while dealing with the new experiences of being a girl.