I always hear of legal troubles with authors who use the setting of one universe whose rights belonged to another publisher, often is the case with the Dungeons and Dragons universe.
That's because D&D is a trademarked product, as are Star Wars, Harry Potter and most big media franchises. Trademarks are taken out by publishers once a property becomes big enough to spread into other media such as movies and merchandising, and can only be applied to the names of characters, settings, titles and other distinctive elements of the property.
This is a whole different kettle of fish from an individual author's copyright of their written works, which remain with the author.
I have heard of one author (Holly Lisle) who is no longer able to write books in one of her early settings because of the contract she signed with the publisher, but this is highly unusual. I don't know if she had an agent at the time, but it's certainly a good reason to get one if you are offered a novel contract.
Short fiction contracts are normally very limited in scope, e.g. you get all rights back one year after publication, so you can in theory sell your story to another market that accepts reprints. Otherwise "best of" anthologies wouldn't exist!