The virginity of the Goddess of Magic was a joke that had been circulating in the world of magic for centuries.
Mystra was born into a large noble family and had been studying magic since childhood with the support of her family. She was a genius who learned rapidly and by the age of fourteen, she was already an Elite Mage and had created the spell Protection From Arrows.
Generally, new spells invented and created by a Mage were related to the environment in which they lived.
Because Melf lived in a harsh environment when he was young, he created Acid Arrow to target trolls and then invented Melf's God-Slaying Spell because of the bullying from evil gods.
As for Mordenkainen, he was born in a time when there were very few Mages and when they were weak, so he invented spells, all of which were offensive spells of various sizes, as well as the spell model system to reduce the difficulty of learning spells to train more of his kind.