Fan fiction gets a bum rap. Somehow, if you write fan fiction, you're not a "real" author. I don't believe that. An author writes. As simple as that. A fantasy author is a writer. A speechwriter is a writer. A cookbook author is a writer.
For readers who may not know, fan fiction is, according to Merriam-Webster, "stories involving popular fictional characters that are written by fans..." These are stories not written and authorized by the author and/or their management or estate. These fan fictions range from regular stories that try to stay true to the author's world to parodies to erotic/romantic pairings of characters.
Aren't media tie-in novels basically fan fiction? All the Star Wars novels, Star Trek books, and dozens of others, in a way, are authorized fan fictions. The publisher is hiring writers to write in a pre-made universe, following the rules of that universe. That's what fanfic authors do: write in someone else's world. You could argue big names like Stephen King and Jeffery Deaver have dabbled in fan fiction. King wrote a Sherlock Holmes short story and Deaver wrote a James Bond book, Carte Blanche.
I began my writing with fan fiction. I remember writing a short story in elementary school using Indiana Jones as the main character. When I began writing screenplays, my first ones were for TV shows I liked: Star Trek, Cleopatra 2525, The Secret World of Alex Mack. I was practicing, and more importantly, I was writing.
I think writing fan fiction is great for two reasons. One, and most important, you are writing. You're getting that story out of your head and onto the paper, or most commonly, screen. Two, you're having fun. You enjoy writing. You enjoy it because you enjoy the characters and the world and you don't want to leave it. Writing is always at its best when if doesn't feel like work.
I think writing fan fiction can be great practice. You can let your imagination run free and make the characters do stuff they would never do. On the other hand, you know the characters and their responses and you can craft stories accordingly, trying to write a story as close to the original as possible. It's also fun to fix problems or things you don't like about the original work. "The story would have better if..." Now is your time to see how it would have turned out had "if" happened.
I'm a fan of traditional fan fictions. I prefer stories that try to remain as close to the originals as possible. With large universes, such as Star Trek and The Lord of the Rings, whole new characters can be invented. Who says you have to use Picard and Gandalf? Go wild! But I think the best ones are the ones that try to remain true, while bringing a newness to the property. They are fun to read, also; seeing how different fans interpret the same universe.
The downside to fan fiction is it is unpublishable for profit. You can't write a dozen Castle short stories, then put them in an anthology to sell on Amazon. You'll be sued out of existence in a heartbeat. You can write them for fun and practice, but if you want to make money writing, it must be original. You can't just take your fan fiction, change the names, and publish it. Your world has to be distinct enough not to cause copyright infingement.
But, in an odd way, fan fiction for TV shows can get you a job. Called 'spec scripts' (for "speculative") writers often write a script for a TV show and pitch it to the producers. If it's good enough, they can get hired. And they did it by basically writing a fan fiction piece.
To me, though, fan fiction is best for practice. By writing and studying the world you're writing in; you're learning characterization, dialogue, structure, and all the rest. Once you feel ready, you can write your own stuff.