In regards to Snape, I'm convinced his appeal comes more from Alan Rickman's portrayal than Rowling's writing.
Rowling stated at one point Rickman influenced how the character appeared in her head.
To be entirely fair though Rickman doesn’t contradict the way the character is written, he just embodied that character so well that it replaces your mental image when you think of him.
I don't have any proof on me, but incidentally, I suspect Hermione is Rowling's self-insert. Rowling outright states she is a caricature of herself when she was 11.
And the fact that she is the most brilliant witch her generation is suspicious. Though, unlike twilight's Bella Swann, Hermione is spared of being a Mary Sue self insert based on the fact that Hermione has actual flaws, and the focus is on Harry.
I vividly remember from my potterhead days (don't judge me) that JKR did say Hermione was her own voice in the story, as in, whenever she told Harry something, it was what Jo would tell him herself. Ditto for Dumbledore. She's more Author Avatar than Mary Sue (except for Hermione in the movies, who is totally Mary Sue).
Rowling confirmed that Hermione was based on herself when she was a child. However Rowling had respect for basic story structure when she wrote the characters that was ignored in the films. Which is how most people know about the character of Hermione.
The character of Hermione is reminiscint of Spock in Star Trek. It’s splitting up your protagonist into three characters. Which is very Freudian. One representing the Super Ego (in this case Hermione) and one representing the Id (in this case Ron) and one representing the “Ego” in this case Harry. Who embodies both traits (he’s half-blooded as opposed to full blooded Rowling was a little on the nose when she did that). This was all but ignored in the films because they wanted Hermione to be a role model for girls. Which worked Harry Potter is extremely successful with women. (To the point where if you poll adult women now most of the films are in their top 10 favourites)
I'm starting to wonder if Rowling just didn't have most if not all of the potter series ghost written for her. Her other works, namely the crime ones, are so outlandishly childish and basic in terms of narrative structure, it's almost a friggin' wonder she even struck gold with harry potter.
Now that the [alleged] ghost writer is gone, she's going back and doing all the stuff she wanted but they insisted wouldn't fly.
I don’t think this is the case. If I had to assume it has much more to do with Rowling planning the series out much more heavily and having a rougher editorial process.
A lot of writers in their early years tend to put out their best work because they aren’t seen as “legends” yet and still have to prove themselves. You can see it with Stephen King for example. Their editors tend to not let them get away with as much shit. I’m fairly certain Rowling planned most of the story beats out well ahead of time when she was writing Philosopher’s Stone as evidenced by the amount of reincorporation of plot details and characters throughout all 7 books. (There’s several plot details sprinkled across each of the 7 books that only really play a major role in 7. )
I think the lack of overall quality with her later works and her retroactive revisions to the original work has more to do with ego and aging. Like Rowling is a more political person now and sees her writings as a vehicle for that. (See the recent Fantastic Beasts film where they for some reason shoehorn in WW2). Prior to this Rowling was concerned over the story and the characters but she now sees them as just pawns in trying to push a political or social message. She is also “JK Rowling” a household name and doesn’t have to prove herself to any of her publishers anymore. They’ll let her publish anything without the slightest criticism. As evidenced by how amateurishly written Crimes of Grindlewald is.
Allegory is something J.R.R. Tolkien consciously refrained from doing when he wrote The Lord of the Rings. Which he stated was not an allegorical tale and was strictly a work of fiction that had no clear interpretation from the author. And he stated this was the case due to how he saw allegory as the author telling the reader “your interpretation is wrong, here’s the correct one”. Not all writers are as principled as Tolkien was and especially nowadays with how politically charged people are.