So, let's take a look at the business side of things today. What is copyright?
(NOTE: While I am going to talk about the law here in my capacity as an author and publisher, I am not a lawyer, and this is NOT legal advice. If you need legal advice, seek out a lawyer.)
The nature of copyright
There are two ways to look at or define copyright (which literally means "the right to copy"):
A bundle of associated rights (publication rights, translation rights, etc.) that are created as soon as a work is "fixed", aka put on the page. These rights place control over what happens to the work in the hands of its creator, and provide certain protections (for example, it protects an author from having a publisher take their manuscript from the "slush" pile and just publishing it behind their back without ever telling or paying them).
A legal framework for contract negotiations. This ensures that terms such as "first English language print publication rights" is always understood to mean the same thing.
The usual copyright term is the lifetime of the creator plus 50 years under the Berne Convention, allowing the creator's heirs to control the work for some time after their death - in many countries, this has been extended to lifetime plus 70 years. Once this term expires, the work enters the public domain, which allows anybody to do whatever they want with it. It should be noted that this entry into the public domain does not have to take that long - the holder of any copyright can place that work into the public domain at any time if they so choose.
While owning a copyright is one thing, proving that you own it is another. There is only one surefire way to prove that you are the owner of a copyright, and that is to register it with your country's government. This is an important thing to do, especially to protect yourself from somebody stealing your work and passing it off as their own - in some jurisdictions, a court of law won't even look at a copyright dispute unless the copyright has been registered, and just about every other way of proving that you were the first to create a work can be faked (even the old "seal it in an envelope and mail it to yourself" can be faked by mailing yourself an unsealed empty envelope to get the postmark and putting something in it later).
Protecting yourself from predators
While it would be nice to say that every publisher goes into every contract negotiation in good faith, the unfortunate reality is quite different. Many publishing contracts have clauses that can be quite predatory (for example, while the publisher owning the copyright to a work is reasonable in cases of licensed fiction such as an official Star Trek novel, it is entirely unreasonable in cases of original work...but this doesn't stop a lot of publishers from trying to get it anyway).
The best way to protect yourself is to keep an eye out for red flags (somebody attempting to acquire the entire copyright being a primary example), and to bring any publishing contract to a lawyer or agent for negotiation.
(And this, by the way, is the fastest way to get a literary agent - if you've already got a contract to negotiate, they will take you on.)
And if the publisher's response to your request for them to give you a few days to bring in an agent or lawyer to look at the contract is to pressure you to just sign it, then run. I'm not kidding.
Limitations of copyright
No creative work is ever created in a vacuum. We draw inspiration from any number of places, including prior works. As such, what one can copyright is limited. One cannot copyright an idea - one can only copyright the specific implementation of an idea. The right to create something inspired by somebody else's work is protected under copyright law and usually called "derivative work".
For example, my book Re:Apotheosis is a derivative work based on an anime series called Re:Creators. It uses the same basic premise - fictional characters come into the real world, meet their creators, and fight one another - but the characters, cosmology, and the nature and details of the conflict are all different. These changes create a new copyright that I own. If somebody were to be inspired by my book and write one of their own with similar changes from mine, that would also be a derivative work that would create a new copyright that they own.
In the case of a copyright dispute over whether something is a derivative work, the question becomes whether the changes were enough. In these cases, the court will compare the two works point-by-point to see if there is sufficient difference between them to state that it is a derivative work. To my knowledge, the exact threshold is usually up to the judge. But, to take an example, if I had just copied Re:Creators and the only changes I had made was to add an "a" to the end of every character's name, it would not meet the threshold of a derivative work and would be considered infringement.
All that said, the threshold for proving that something is not a derivative work is usually VERY high. A copyright infringement case against CBS regarding Star Trek Discovery's use of tartigrades (Abdin v. CBS Broad) was dismissed on the grounds that the stories were not substantially similar enough, despite the similarities being very eyebrow-raising. While I am not able to offer legal advice, I will say if I was publishing somebody who had taken their basic idea from another story, so long as they are using their own characters and have put their own spin on it, I wouldn't be worried.
(Less important for the purposes of this guide is fair use/fair dealings - this is the limited reproduction of copyrighted material for purposes of demonstration or criticism, and this is also protected under copyright law.)
Copyright Infringement
If somebody violates your copyright - either by passing your work off as their own, publishing it without your consent, or using your characters or setting without permission - this is called "infringement." What happens afterwords is up to you.
Unlike trademark law, there is no obligation to enforce copyright. While a trademark owner risks having their trademark declared to be abandoned if they don't enforce it (which is the reason Disney is so protective of mascots such as Mickey Mouse), no such hazard exists for a copyright holder. So, if you discover that somebody has infringed your copyright, you have decisions to make about what - if anything - to do about it.
In cases where somebody has passed your work off as their own or published your work behind your back, you will almost certainly find it worth your time to act, particularly in the case of the former. Speaking as an author and a publisher, these are not precedents that one ever wants to encourage. However, somebody writing clearly marked fanfiction without any attempts to profit from it is often a very different case - there's little to no risk of confusion over who the original creator of the story, characters and world are, and enforcement even comes with a risk of alienating part of the fanbase (particularly if the copyright holder is a large corporation). In cases of fanfiction, it really comes down to whether you are comfortable with somebody else playing with your story, world and characters.
If you decide that an infringement is actionable, you have a few options. For an online publication, you often have the option of using a DMCA copyright strike, which is something you can do on your own, and websites will often be receptive to it. If you do use this, keep in mind that due process is built into the DMCA, and the person who posted it does have the right to appeal, and in a worst case this can escalate to a court of law. You can register a complaint with the website in question, which is another thing you can do on your own. Another option is to consult a lawyer and start the process of legal action.
(And, at this point, going any further would cross the line into legal advice, so this is where this section has to end.)
Just to reiterate, though: the only time where there would be any possible danger of losing a copyright is if somebody stole your work, passed it off as their own, and convinced a judge that they had created it first (and registering your copyright protects you from that for a small fee). Outside of that, there is NO risk of losing your copyright due to non-enforcement - it is yours until the day you die or you decide that you want to transfer it to somebody/somewhere else.
And that's what copyright is, and how it works.