There are several reasons, though, why I think this choice is perfectly reasonable. Although it is a police procedural, Castle has an element of whimsy and fun that isn't found in shows like Law and Order and CSI. The show regularly includes murders that touch on scifi/fantasy elements; season 2, for example, saw the possibility of vampires in the episode "Vampire Weekend" and the curse of an ancient mummy in "Wrapped Up in Death." Seasons 3 and 4 had aliens, superheroes, zombies, and magic--or at least, that's what Castle theorized. So even though Castle is mostly about solving murders, the inclusion of fantastic elements, even as silly theories, in the process of solving these cases puts it on the borders with science fiction and fantasy.
But the strongest connection that I see between Castle and science fiction/fantasy is in the casting choices the show makes. [caution: spoilers about the casting of the season 4 finale follow]
For starters, and perhaps most obviously, Nathan Fillion is the show's titular character, and for those of you who don't know, he was Captain Mal on Firefly and Serenity, and he appeared as the villain Caleb in Buffy the Vampire Slayer. He was also part of the Internet-distributed Dr. Horrible's Sing-Along Blog--all scifi/fantasy shows.
Now, it would be one thing if Fillion were cast in Castle and no connection were made to these other shows--then it would be just an interesting bit of trivia, another line on his resume. But this isn't the case. Rather, Castle has gone to great lengths to draw connections to Fillion's previous work, specifically on Firefly. Perhaps the most notable example of this comes from the episode "Vampire Weekend" in season 2, when Castle dresses up as a "space cowboy" for Halloween. Here's the clip:
A similar effect was achieved this season with the casting choices for two of the guest stars. For starters, in the episode "Headhunters," Adam Baldwin (who played Jayne Cobb on Firefly) guest starred as another detective that Castle shadows. While his character on Castle shares some similarities to Jayne, the relationship between Baldwin's characters and Fillion's characters on each show is quite different--on Firefly, Mal is the one who bosses Jayne around, while on Castle, Castle was scared out of his mind by Detective Slaughter. Because of this casting choice and the intertextual relationship between Castle and Firefly, we are more aware of certain aspects of Castle's character and are better able to track his development over the course of the show.
And then, on Monday's season finale (which, by the way, was fantastic), Tahmoh Penikett was cast as one of the conspirators in Kate Beckett's mother's murder. Penikett is best known for playing Karl "Helo" Agathon on the Battlestar Galactica reboot; he was also FBI agent Paul Ballard on Dollhouse. The connection between Penikett and Fillion is not quite as strong as that between Baldwin and Fillion, although both have been cast in TV shows done by Joss Whedon, but Penikett's appearance on the show further reinforces the connection between Castle and the fantastic, and puts the show into conversation with a whole host of shows such as Buffy, Dollhouse, Chuck, and Firefly that it might not otherwise be considered alongside.
But, as I would ask my students, so what? What does it matter that these connections are made? Is there a point, or is this just fun trivia to impress people with at cocktail parties?
I would suggest that the ties to science fiction and fantasy are in fact one of the key points of the show. Time and again, we see how important Castle's imagination is in solving cases. Sure, he comes up with some ridiculous theories, but quite often, his out-of-the-box thinking is what jump-starts a stalled case or provides Beckett with just the right insight to finally make a connection between victim and killer. Certainly, his imagination leads to silliness and fun, as seen in the many episodes involving zombies, superheroes, and other assorted costumes, but it also helps solve cases.
And by deliberately drawing attention to connections between Castle and scifi/fantasy shows, the shows creators are reinforcing this idea--namely, that imagination is certainly fun, but it's also much more than that. It's what enables us to think up new things, to imagine other possibilities, and ultimately, to change the world around us into a better place. And who better to lead us into this new world than Captain Tightpants?