God created man and woman. This is biblical truth and it is impossible to have a world that is composed purely of males, or purely females. Thus it seems impossible for one to have a fear of the opposite sex because there are males and females everywhere.
The fear of the opposite sex is called sexophobia and this could have been brought about by a traumatic experience. For instance, a female could have had an abusive father, or abusive boyfriend or husband, or was subject to discrimination especially in countries where females are considered to be less important or are second class citizens.
For males, the fear of females is unimaginable but could be due to being heartbroken for instance, had a mother who abandoned her, or lived with an orphanage who’s caretaker treated him like he was not a significant being in this world.
This fear could be also sexual in origin. One might feel extreme anxiety at the thought of having interaction with the opposite sex and procreating.
Females with this phobia might opt to live a life of solitude as a nun in a convent, or would choose to work in a workplace composed only of females. For males, they could also become priests and have a vow of celibacy.
Treatment includes behavioral and cognitive psychotherapy.