If fanfiction is legitimate, doesn't that mean publishers or studios can produce derivative works without compensating original authors?

No. Profit matters, and the degree of transformative quality matters: telling stories around a campfire, freely sharing nonprofit fanfiction, summarizing plot in a book review, or making a documentary film about fans is not the same as a major commercial derivative enterprise like making a major TV miniseries out of a novel.