One mistake people make about science fiction is it's not really a genre. It's a setting. Mystery is a genre. Romance is a genre. Action/adventure is a genre. Thriller is a genre. You can do any of those things in a sci-fi world; you can do any of them in a swords & sorcery world.
Science Fiction is part of the larger Speculative Fiction category. The Speculative Fiction cateogry includes what most people will call sci-fi and fantasy, with a small dip into horror. Speculative fiction category is used by many larger bookstores to lump sci-fi and fantasy together in one category so their staff do not have to make judgement calls on which book is which.
The main problem with the concept of genre is that it is fairly ill defined by the literary community, with problems compounded by its uses in the film, comic, and gaming communities.
The best generic definition is from Websters:
genre \Gen"re\, n. Kind; genus; class; form; style, esp. in literature.
A particular demand . . . that we shall pay special attention to the matter of genres -- that is, to the different forms or categories of literature. --W. P.
Source: Webster's Revised Unabridged Dictionary, Ãƒâ€šÃ‚Â©
1996, 1998 MICRA, Inc.
Working from that, Sci-fi defines any story revolving around Science, while Fantasy defines any story revolving around Magik. These are broad, sweeping, generalizations that I hope you all forgive me for. There are books that overlap Sci-Fi with psionics (the sci-fi codeword for magik) in it like Darkover and Pern and countless others. There are fantasy stories
that have science (Mercede's Lackey's later Valdemar books had the impact of science- watchtowers and other things- on their world). Lets just stick to the generalization for the moment.
The Sci-Fi genre has the primary tropes of, or tends to deal with, science and technology, space and aliens, and the future (near or far). A story can have romantic, adventure, or mystery subplots or story arcs, but still focus on the one of the tropes listed above, and be in the science fiction genre. It is the focus that makes a story science fiction. Hard Science Fiction revolves around the Science. Soft scifi, tends to have "fuzzier" science. However, the focus of the sci-fi genre story needs to revolve around the science and technology (and people's response to it), space, aliens, or the future of humankind.
Asimov's Robot Detective series is sci-fi, even though they are mysteries because the mysteries revolve around the technology of robots.
A story can have these elements, but focus on something else. This would be stories that have a sci-fi setting, but have the tropes of another genre
(romance, action, or mystery). There are dozens of romances set in fantasy, sci-fi, horror settings. We don't call them fantasy or sci-fi or horror, we call the Romance novels. It is all on the emphasis.
Star Trek stories tend to focus on the people and their interaction, with the technology/ science taking a back seat. Most episodes and books could be set in another time and place and still work as a story. Many Robin Cook and Cricton books are not sci-fi genre, but are definitively of the sci-fi setting.
These are just my thoughts. If you want to discuss this more, you know what to do....