Willie the Duck
Hero
I don't think anyone is talking about not having hoardings atop the walls, nor the primary donjon not having a roof. What is being discussed is castles with walls guarding large open baileys, with walls that, for the most part*, are focused on repelling forces concentrated outside -- where major threats being able to fly over and land inside the defenses would be a significant problem against which the general setup was not designed.The open topped castle is an anachronism even in the real world and has to do with the fact that in warmer climates in Europe, hoardings were generally made of wood and often constructed only in wartime and neglected otherwise. Thus, the Edwardian castles people are familiar with in ruins are open topped today because the wooden hoardings long ago disintegrated or were purposely dismantled (Edward's castles generally served their purpose of pacifying Wales and integrating it into the culture and economy of England), but which would not have been open topped if the castle was expecting conflict. However, castles in Northern and Eastern Europe tended to have permanent stone and tile hoardings covering the fighting positions atop the walls and towers. And historical castles not only had arrow loops but in their final stages also cannon loops for destroying whatever siege equipment was brought against them, so the whole "ballista" thing isn't entirely without merit either.
*although defending even if the walls were breached certainly would be part of the plan.
I would call fantasy air forces rather rare in my experience. However, there is always the occasional dragon or manticore attack. In general and across time, I've tended to see defenses against such occurrences that are more 'here, we're showing we know that flying creatures are a threat' level than actually sufficient to take out dragons or multiple mid-sized flying monsters. 5e making several dozen archers on the wall be a real threat to dragons has probably changed that math.Generally speaking, if fantasy air forces are a thing, then fantasy castles are also air bases where fantasy air forces are stored safely. But it's not a given that in a particular setting you have fantasy air forces more common than Bellerophon on his steed.
I'm not prepared to speak to the breadth of D&D in-book fantasy art, nor to 5e adventures, but overall in D&D castles which show up in adventures and have castle maps seem to follow the donjon-in-bailey-surrounded-by-walls model.More often, what you actually see in D&D is fairy tale castles along the lines of Neuschwanstein which represent not castles as they actually were but romantic images of castles as we wished they were or how they appear in our fancy. Certainly, for example, Castle Ravenloft is such a castle.