This question already has an answer here:
There are a number of questions on this site which query the internal logic of the Harry Potter world. Here's a couple of examples:
I could quote more, generally about economy, geography and employment in the wizarding world. I suspect most people who've read all the books have probably been struck by one or more such questions as they've gone through.
Of course, it's a testament to the skill of the author and the wonder of the world itself that these omissions don't really spoil most people's enjoyment of the story. The suspension of disbelief is extremely strong, partly precisely because Rowling has chosen to focus on the narrative over the consistency.
One of those linked questions, the one about Quidditch, is mine. I recently added another. After which I began to wonder: what if this isn't just the result of an author being more interested in story and characters than they are in consistency? What if Rowling intentionally made aspects of the wizarding world nonsensical in order to make points about modern society?
Take Quidditch. It leaves much to be desired as a sport (see answers to linked question above), yet many Wizards seem oblivious and remain fanatically devoted to it. Could this not be read as a wry commentary on the fanatical devotion shown by many sports fans to what are, after all, relatively inconsequential pursuits? And the "poor" nature of some Wizarding families in spite of the magic available to them. Again, perhaps a comment on how a rich western society still relegates some people to live in poverty, in spite of the wealth of the nation?
Other authors have form here. Kazuro Ishiguro is on record has saying he's not interested in whether his fantasy worlds make any sense, merely in whether they work to help examine his chosen themes.
A question about allegory is, to some extent, unanswerable. Unless the author has specifically commented on whether or not the allegory is intentional and/or accepted by them. So this is my question: has Rowling ever intimated that some or all of the logical inconsistency in her invented world should be read as allegory or metaphor?