Random mutation. It happened to occur in women and then stuck around because it didn’t hinder the population who had it. It was probably just as likely to happen among males, but didn’t, because “just as likely” was obviously something of a long shot anyway, given that this hasn’t happened in very many other species.