Let's be real.
Rowling started out making a fairly bog standard magical kids book. It was all about the fantasy of being a wizard, and relied on tropes so old they get found in La Brea.
This isn't a bad thing. There's nothing wrong with that kind of kid lit.
But she wasn't a good writer. She was mid tier at best. So the eventual success of the series got beyond her abilities. While the last book was much better overall than the first few, it still relied on shoddy world building because she had chased sales.
She tried to turn a kid's light fantasy into a YA fatasy-adventure. To an extent, it worked. And I don't mean that it wasn't successful, she had a hit on her hands because the idea behind it all was brilliant. It pulled from a long history of British youth fiction, and added in fantasy and magic and a ton of tropes.
But from the perspective of a coherent story in a coherent world, ignoring the success in terms of sales, it was cobbled together without a plan, and it shows. It wasn't until maybe order of the phoenix that she had a plan for how the story would end, and she had to do a lot of hand waving to make it happen.
Again, that's okay. Nothing wrong with a bit of light fiction. But, it had cultural impact way beyond its original scope. So it draws the same kind of analysis that something like LOTR does, and it just can't compare. It barely holds up to comparisons with Narnia, and Narnia at least kept things vague and mystical without trying to get into the mechanisms under the hood.
For whatever reasons, Harry, in the books, long before the movies, resonated with kids. So the series exploded. And now everyone pokes at it like it was ever supposed to be literature, with any serious thought behind it. It was all broad brush strokes on construction paper from the beginning, expecting anything in it to hold up to scrutiny is like expecting politicians to be honest and up front. It is what it is.