That’s bad writing.
Eddie Valiant: You mean you could’ve taken your hand out of that [hand]cuff at any time?
Roger Rabbit: No, not at any time! Only when it was funny!
Kind of a terrible example. WFRR has good world building that holds up. Roger is a toon, and therefore must obey Toon Law. He literally, physically, could not remove the cuffs unless it would be (objectively) funny to do so. Eddie being humorless us why he’s an effective foil and investigator; the toons have trouble working him because he doesn’t find them funny.
Toons also aren’t supposed to be able to kill or die, which is why they need a detective in the first place: the world has well-defined rules which have apparently been violated.
The HP world has flimsy rules that depend on the character and the story. The rules of magic are only enforced until an exception is needed, when one is justified to let a character do what the plot demands.
Great point about Toon Law. I guess the HP is more about the Plot Demands This tropes. tbh I don’t know HP that well, I found the movies to be kind of boring and I never got past a couple chapters of the first book.