Switch is a massively popular system and Hogwarts Legacy is a massively popular game.
It's the same reason that saw Call of Duty get ports to the Wii, despite them having to be extensively downgraded to run on it.
Japan is also a factor; they love Harry Potter, but they do not love Playstation or Xbox.
Their CEO of games commented on this a few days ago: “We see the Switch version as a huge success due to its installed base and its fan base, with the Harry Potter franchise obviously attracting a really large audience globally. With markets like Japan where Nintendo is largely widespread and where Harry Potter is very strong in terms of popularity, we expect big results from the Switch version."
As for the game not being worth it if it's downgraded, it's worth bearing in mind that casual gamers don't care as much about graphics as more enthusiast gamers. Look at how popular Pokemon Scarlet and Violet are despite them looking and running like crap.
Canceling the Switch version and going for Switch 2 instead is certainly a possibility, but we have no clue when Switch 2 will come; Nintendo just confirmed it's not happening this Financial Year, so it could be as far off as end of 2024 or even 2025.
Pokemon has a literal cult of fans who are not even gamers, just Pokemon fans. It's a game where a mainline entry never sold less than 15 million regardless of which was the system it gets releases, does it have Pokemon in the title? They will buy it. Although HP fandom is huge they are book fans, or movie fans, not gamers. They could buy any new book with JK Rowlling name in the cover, or be present to any new movie with Harry Potter in the title and that's how I know their next HBO show will be huge
However when it comes down to gaming things are much less certain. Will the name alone be enough to make the game compelling to buy it even if you know the game is severely compromised?
I don't think so. I indeed think even if this game gets released on Switch I believe it won't outsell PS4+PS5 versions in Japan despite of how huge the franchise is and how big the system is.