I'm not saying that it's good that Nintendo takes down fangames, or that it's bad that Sega doesn't. Honestly I think it's terrible that Nintendo is so ruthless with taking down everything their fans make. I'd love for them to be like Sega and support fan content.
The video that ThomasWinwood posted above is a great watch to explain it, and I'm mostly just paraphrasing some of the points in that video, but:
"Copyright law basically forces them to be highly defensive of their IP because they stand to lose a lot if the value of the brands that hold up their entire company weaken" is the *reason* they do it, and in their position is basically their only option. Pokémon is literally THE most profitable multimedia franchise of all time, and Nintendo is desperate to hold onto the exclusive rights to it, which means they immediately stamp out anything they see as threatening/competition, no matter how small, because they can't afford any damage to the value of their brand, which as a media company, is extremely valuable to them.
And Pokémon is the most profitable media franchise in the world *in spite* of everything they supposedly do wrong, even with the fans declaring every new game since... probably at least Diamond/Pearl to be the worst, most unforgivable games ever how could you do this to us wtf game freak i'm never ever ever ever buying another pokemon game ever again until the next one comes out, until the kids who grew up with those games get older and suddenly they're amazing underrated gems (The fanbase's general opinions of Generation 5 now vs back in like 2012 are VERY different), even with all the "wasted potential" the games have, it's outperformed *everything*. Nintendo doesn't view the community relations and free advertising to be worth the potential damage to their gold mine of a brand, and they don't have the resources to manage their fanbase. They've arguably pissed off the community plenty, and they still succeed despite that, so it's not really worth it to "love their fans" to them.
This was a bit of a ramble but tl;dr it's basically copyright law and capitalism's fault for making it more profitable for Nintendo to nuke fangames from existence and it's not just a simple case of "they want to be mean because they feel like it".