This I kind of agree with. Not every loss or setback in a game with random elements provides a valuable lesson. Sometimes bad luck just strikes. There will also be times of extremely good fortune. It is important to let players know when extremely poor judgment was the proximate cause of a disaster. If players are unaware that they are making mistakes there isn't much chance of learning from them.
I'm going to have to disagree with you here. In fact, I'm going to make a blanket statement here that might sound controversial, but I think is completely totally true.
Bad luck, or randomness, NEVER causes TPKs. TPKs are always a DM's choice.
Think about the actual odds of a TPK by dice. You would have to have every PC suffer enough damage simultaneously to drop them to negative con, which I would argue is an encounter the DM has designed to kill the PCs (see my earlier post about the logic of game results). Or, through combat, each PC would have to be reduced to zero, then fail three death saves before they passed three. The odds on this happening to 4-5 characters is pretty slim. Even in a case where it is logical for all of the PCs to be knocked to zero (surrounded by mobs), everyone failing the death saves is still highly unlikely. Death normally comes in this situation from the DM
choosing to have the mobs kill the unconscious PCs.
Now, people can argue about what goblins would do until the cows come home, but the fact that any mook kills a helpless PC is totally based on DM choice. There are as many reasons why a mook wouldn't (even down to pure laziness of not checking each body) as there are conjectures why they would. This is even more true with animals (who are more likely to drag off a kill and eat it, leaving the rest until a later time... or even abandoning them). While a PC or two can certainly die from bad rolls, the only way that a TPK can happen is by a DM choosing to have the mooks behave in a manner that would do so.
Now, as I talked about up-thread, some groups are ok with this line of reasoning. In fact, some players would follow the logic to the point where they would be upset if a DM didn't TPK them. That's perfectly OK. But it's not more "logical," or "hardcore," or "simulationist," or even "game as war" than other logical outcomes (even in most combat situations, soldiers don't finish off wounded enemies; in history those who did often got very unsavory reputations... See Banastre Tarleton)... often it is less so. It is dependent on the social contract shared by the players and the GM as to what the "logical" outcome should be (i.e. what the fair choices are for the DM).
As an aside, this is one reason I am glad that 5e doesn't include an instant-death coup de grace option. Use of this by a DM is almost always a dick move. Now, certain tables may see the process as a logical one, and therefore accept the DM's choice. But that doesn't minimize the fact that, whatever rationale is present, the DM is purposely destroying a PC (an item of great value to the player) where the player has no such reciprocal power over the DM.
To the OPs situation: the PCs were in an encounter they could not survive outside of the conditions set by the adventure (that the dragon would not use its breath weapon against the PCs and it would retreat after a minor amount of damage). The DM ran the encounter without noticing those parameters and the PCs died in one hit. Please show me how the characters died by their own poor choices in this (especially since the encounter was designed for them to fight the dragon!)? In this case, the DM made an error in judgment (not a malicious one, for sure), and he chose to TPK them. The DM then retconned the results because of his mistake. I think this is both honorable and laudable. It takes a tremendous amount of character for a person to admit that he was wrong, especially in a position of absolute authority like a DM. The OP should be praised for doing the right thing here, especially since his group seems to share his opinion of what is "fair."
To your comments: when an event occurs where the logical outcome of the players choices would be for the players to lose, and they do so, I don't think you normally need to tell them, "That was stupid." It's usually pretty obvious. You may need to explain the logic of why you decided the unconscious and stable PCs would be killed. That will tell you what kind of group you are playing in...