They are young adult fiction, which is like saying that cars weren't built for driving. I'm not sure what you intend they were written as then, as they surely aren't literature.
The Harry Potter books are children’s literature. Not young adult. At least the first four or five are.
Notice how they’re almost all divided into very episodic chapters. That’s because children’s novels are generally built for reading maybe a chapter or two at a time. Maybe before bed or during reading time in a classroom.
I suspect the intended distinction is between literary fiction and genre fiction, which is a quirky socioeconomic split that seems to be particular to the realm of novels and their authors. Basically, authors of literary fiction are regarded as masters in pursuit of True Art rather than baser desires like popularity or commercial success.
Notice how they’re almost all divided into very episodic chapters. That’s because children’s novels are generally built for reading maybe a chapter or two at a time. Maybe before bed or during reading time in a classroom.
Also those books are very much literature.