I think this is more about following the Hero’s Journey rather than Harry Potter being a rip-off of Tolkien. I mean, sure there are giant spiders and old men with beards, but the stories and the magic systems are fundamentally different!
I always have an issue with people who claim that any fantasy containing orcs, elves and dwarves is automatically ripping off Tolkien. Sure, they took cues from the way he describes those creatures (which comes with its problems because dwarves are kinda coded to be a Jewish stereotype, which is yikes), but at the end of the day, that’s much more to do with short-hand. Not a lot of people want to spend ages and ages explaining their magic system and going into great depth about their world-building. Using creatures and races that already exist can prevent you from needing to go off on world-building tangents. You can just get into the story without worrying!
After all, is Percy Jackson a rip-off of Greek mythology? What about Thor with Norse mythology? It’s more about what you do with the magical races you include rather than if you use the same ones as something that came before you.
Although saying that, it is extremely unimaginative to just use the races mentioned by Tolkien, not to mention insufferably euro-centric! The rest of the world has some amazing races and creatures, too! I mean, Japan is known for its awesomely scary stuff, for one! And they have some awesome gods we can draw inspiration from like Izanagi and Izanami. Then you have West African/Caribbean folk tales like Anansi the Spider (thanks for bringing attention to that, Neil Gaiman!)
But yeah. There are also plenty of fantasy stories that don’t have many similarities with Tolkien at all! One of them being Skulduggery Pleasant!