It is unfortunately true that totally unique fiction is extremely rare. Whatever we write, the chances are that somebody got there first. That said, there’s no reason to suppose that a writer has ever encountered the earlier work. Sadly, however, some fiction is very clearly at least derivative. There may be no conscious effort to copy the work of earlier writers, but we store vast amounts in memory and it’s liable to leak out at any time.
The worst sin in writing is straight theft of another’s work. Say a famous writer receives a manuscript from an unknown author. They’re experiencing a total block and deadlines are pressing. It is very tempting to simply claim the unknown writer’s work as their own. Of course, that is a huge risk! If the unknown can prove that the work is their’s. then the well known author is ruined. Almost equal in status is plain plagiarism. Virtually copying another’s work, perhaps styling it to suit the plagiarist‘s known form, is as likely to ruin the author as theft. Neither can be excused.
So-called fan fiction comes in two brands. The first takes something like a game or movie created by others and generates writing to suit, expanding on the world the writer is a fan of. The second is similar but involves expanding the creation of another author. Many fans feel unsated when an author decides to end a series of stories. Hooked on` the world the author created, they write their own tales based on the same world, and maybe even many of the same characters. Only the original author can decide whether such works are legitimate, and many choose to protect their creations and stipulate that others have no right to use their work in this way. Some fan fiction is well known, however. For example, Robert E Howard‘s Conan stories have been expanded by other writers, by permission.
Derivative works are similar to fan fiction, in some cases. No attempt is made to create everything from scratch. Names and certain details are modified to make the new work appear to be original but it isn’t difficult to discover the truth. Such works are the result of laziness, generally. In other cases, the derivation is less obvious, being a complete reworking of all but the central theme. This may be because the theme itself fascinates or inspires the author, driving them to take it up and put there own interpretation on it. That’s not hugely different, in essence, to the way different writers produce works based on the same social issues.
Finally, don’t be too quick to point fingers and shout “Foul!”. You need to be sure that a writer has deliberately hijacked somebody else’s work. A superficial resemblance isn’t plagiarism. Taking parts of other works and assembling a jigsaw of those parts isn’t right but remember that there is a limit to imagination, and most authors write based on their own experiences or reports of real life events. If something seems too similar to another work, but you can’t actually pinpoint exact, or near exact, copying, then just set the derivative piece aside and stick with the original. Also, bear in mind that you may actually believe that a work has been plagiarised when, in fact, the “original” you think of might have been written much later! Check the original publication dates before making accusations.