Hypothetical: 1 Dragon vs 100 peasants (commoners)
First, the idea that dragons would not be unstoppable killing machines for NPCs was a design choice. I remember an article long ago talking about this, that cities should be able to defend themselves. If the cities couldn't dragons would rule the world which for most campaigns they do not.
But lets say you had a village threatened by a dragon. Present <whatever dragons want> or you die. So the villagers wait outside the village in a field slings at the ready and wait for the dragon. What happens next?
I'll use an adult red dragon because in 5e they don't have their fear aura. They do have an AC of 19, 256 HP. They also have above average human intelligence (16) and wisdom (13). In addition to their 30 foot cone breath they can also cast fireball once a day (range 120 feet) and scorching ray once per turn as a legendary action (range 120 feet).
In the other corner we have peasants +2 to attack, no damage bonus using slings (range 30/120), damage 1d4. They only have a 10% chance to hit, half of those hits if the attack is done within 30 feet so 2.5 damage for a regular hit, 5 for a crit, average for 3.25 damage on average per peasant with crits. It's .25 if the dragon has cover (see below). Long range is a bit iffy because they'll have disadvantage and I'm not sure how to calculate that so I'm just going to cut that down to 1.6 per peasant. I'll call it .05 if the dragon has cover and it's long distance (again, not sure how to calculate that).
Assuming completely empty field, no cover, all peasants 5 feet apart in a 10x10 grid. To benefit the commoners I'll assume they see the dragon coming and win initiative. I'm also going to do this as much as possible by strict rules interpretation, for example I'm not sure the back rows would even be able to hit the dragon if the dragon is on the ground simply because of all the people in the way.
Options
#1) Suicidal dragon
Continuously fly over the enemy giving them clear shots every single round.
Round 1:
Commoners: Because the dragon is cooperating with the commoners and always within 30 feet we get 325 damage. Yep, this is one suicidal dragon. There are old dragons, there are bold dragons, there are no old, bold dragons.
#2) Stupid dragon
Fly straight at the peasant formation, land and breath fire at the edge.
Round 1:
Commoners: those within 30 feet do 3.25 damage each so for simplicity I'll say the first 5 rows are within 30 feet and those in reach of the dragon are attacking with clubs which also do 1d4 damage. Problem is, only the front row has a clear shot, the dragon has partial cover after that from the people in front of them. So we have 10x3.25 + 40x0.1 = 36 damage the first round.
Dragon: The dragon breaths fire taking out 38 peasants.
Round 2:
Commoners: Peasants rush up, some of them pulling clubs to attack. They also change formation a bit but these are not trained soldirs. For simplicity I'll say everyone can now hit, but still only have 10 that can attack without cover. So 10 front row and 52 attacking dragon with cover for 10x3.25 + 52x0.1 = 37.7 rounded up to 38. Dragon is now down to 174 HP.
Dragon: fireball takes out 40 more peasants, they're now down to 22 commoners.
Round 3:
Do we really care? There's no way the commoners can win.
#3) Why the heck would the dragon attack them?
The dragon ignores the formation, goes and burns down half their village because all the commoners are in a field not protecting their village. Better pay up or the rest burns.
#4) Attack at night
If these are humans, just wait for cover of darkness. The dragon has 120 foot darkvision, just fly around blasting breath weapon. If these are any other race and have 60 foot darkvision, it's a little trickier but unless the dragon is suicidal they still win. They could always just use their scorching ray from just outside the NPC's visual range. It's going to take a while but eventually the commoners will lose.
#5) Tactical dragon
Fly overhead out of the reach of the weapons and drop stuff on the peasants. They're huge with a 27 strength they an carry 1,620 pounds before they become encumbered. Pick up trees, set them on fire, drop on defenders. One of my favorite tactics for massed troops.
I'm sure there are other options. I also think this is a highly unlikely scenario that the commoners would know the dragon is coming, be prepared and standing out in an open field. Even then if you actually work the scenario out and follow the rules of the game, I don't see how the peasants win unless the dragon is suicidal or there are other circumstances giving the peasants significant advantage. Even if you assume something like England during the era all able bodied men were required to train in the longbow, it's only the suicidal dragon that is truly threatened.
So no, I don't think 100 commoners will kill a dragon unless the dragon is suicidal or the game is rigged against them.