I feel that the D&D rules really lend themselves to adventures that involve heroic characters, copious amounts of violence, and the accumulation of an obscene amount of treasure. And very often players have a D&D mindset because the rules push them in that direction which I don't think is appropriate for every game. So if I want to play a game where the typical D&D mindset would be inappropriate then I'm better off switching to another set of rules.
I usually define/describe D&D as doing
heroic fantasy adventure.
Heroic: the characters are action-movie heroes. They do amazing things, are expected to win, and are tougher than normal folk. The whole concept of hit points leans into this and supports it - which is why this is the hardest thing to get away from. It's why D&D doesn't work well for modern- or pulp horror. PCs are too cool for that. (It works for Hemmer-style horror, though.)
Fantasy: Out of the box, D&D does D&D fantasy, which is it's own subgenre based on an Intellectual Property. But it's neither hard nor complicated to add or remove content (monsters, items, classes, etc) to change the type of fantasy, and with enough work you can push it to a lot of different places, including most of Sci Fi. So long as it stays heroic, and you're willing to do the work, you'll be fine.
Adventure: the macro game loop of D&D is the adventure: go somewhere dangerous (the dungeon/hexcrawl/etc), have a series of encounters, get rewards if you succeed. You use those rewards to get better at overcoming challenges, which means you can go on more difficult adventures, which have bigger rewards. Cycle again. If you get away form this, the rules stop helping you. They don't actually interfere with not-adventure play, but they aren't on your side anymore.
For example: Star Wars is a great setting for D&D, and D&D serves that setting well.
Now, this is where I agree with
@doctorbadwolf : The types of encounters possible with a little bit of work are just as broad as the fantasy genre. You can do fights, heists, negotiations, chases, pod races, sinking ship escapes, interrogations, traps, puzzles, and more. You don't need a bespoke system for any kind of encounter. D&D can handle them, if you're willing to make and/or find some good houserules (which isn't
that hard). A more bespoke system might be a great place to mine ideas, but you shouldn't switch systems for an encounter. You switch systems for a different overall play experience.