Stories like Fifty Shades of Grey come to mind, as does The Mortal Instruments. Two very popular stories that started out as something else entirely.
Is this illegal? No.
P2P is not illegal because plagiarism is considered merely unethical; it is morally criminal not legally criminal. It could be considered copyright infringement, if it utilized enough elements from the original author's published works BUT most fan fiction authors who choose to p2p, have the sense to change character names and locations... And chances are, the reason the fanfic was popular to begin with, was because it was vastly different from the work that inspired it. The end result is characters and places eerily similar to another work, but a plot line that is extremely different. Even if one author decided to sue another over copyright infringement, it would be difficult to prove infringement had happened unless the new work contained sentences and phrases unique to the old work.
This act of pull to publish is a blurry line. Fanfic-authors-turned-original, don't want their fans passing around PDFs of the fanfic version because it might affect their book sales. Alternatively, the author's fans might run out to buy that book, encourage others to buy it, and discourage others from reading the free version. It isn't illegal to pass around that free PDF, nor is it wrong to have that story on your Kindle or bookshelf, if its truly what you want to spend money on.
Now as someone, who occasionally dabbles in fan fiction, because 1. books get expensive, and 2. it's just entertaining, I can honestly say the for-sale version is often disappointing. I have indeed bought one and I've scanned a few others. The common denominator between books that are considered p2p, is that there is little alteration between the 1st draft and the published draft. So this person change some names and phrases, so what? It is still written poorly, which is just fine for fan fiction because fan fiction is free and you get what you pay for, don't you?
But when you're asking people to shell out hard earned cash, how do you justify pimping a book that is not only riddled with grammatical errors, but the plot line is now in question, if only because things that make sense in fan fiction world no longer make sense in the world of published fiction? And who agrees to publish these books? I don't mind independent authors and editors as long as they do the job correctly. Small businesses need business too. But the Internet has made it easy as pie for people to market themselves for a job they might not be qualified for.
And you can pick apart these books, and find fans willing to defend them.
Against: The grammar is bad.
For: The grammar doesn't matter if the story is good!
Against: The grammar does matter and the story isn't good.
For: The story is awesome, why'd you read it if you hate it so much?
Against: How do I know if I hate unless I read it?
There is no sense arguing. People who love it will never understand people who don't, and vice versa.
As someone who enjoys fan fiction, the free kind, I am of the group that does not love it. First, the writing sucks. Second, the editing sucks. Third, why would I spend money on something that I can enjoy for free? Fourth, ever hear of artistic integrity? You took the work that someone did before you and you put your own spin on it, decided at the last minute to package it up and sell it. For this 4th reason, I will never again knowingly purchase something considered p2p.
If you're a fan fiction author, and you want to get published, I support you. Everybody has gotta start somewhere. But do the author you love a favor, do your fans a favor, do your reputation a favor: Write something new, something no one's seen before. Don't be just another hack riding the coattails of a better mind.
(Feel free to give your opinion on the topic)