Long story short, Stephanie Meyer told the writer of the fan fic “Uh... That’s not appropriate for my characters or my forum.”
[A laugh considering.}
So butthurt fanfic writer takes the manuscript, changes the names, adds a few extra paragraphs maybe, and submits it to a publisher.
Publisher bought it.
And here we are today.