Your question did not establish any contradiction, if you look carefully at your examples of commenters telling us things.
The brayta on Bava Metzia 58b discusses causing pain to people with your words, by reminding a descendant of converts of his ancestry, a convert of his previously eating non-kosher food, of someone currently undergoing suffering that it is all his fault, or making a prank by directing donkey drivers (pizza delivery folk) to someone who doesn't sell grain.
It is possible that the author of the brayta maintains that afflictions of love (yesurin shel ahava) are possible, such that (as we see in Berachot 5a) after searching one's own actions and finding no fault, he might conclude that these are afflictions of love. It is possible that the author of the brayta possesses seichel that others don't, and know that there is a time and place for telling someone this. As we see in Pirkei Avot, 4:18:
רַבִּי שִׁמְעוֹן בֶּן אֶלְעָזָר אוֹמֵר, אַל תְּרַצֶּה אֶת חֲבֵרְךָ בִשְׁעַת כַּעֲסוֹ, וְאַל תְּנַחֲמֶנּוּ בְּשָׁעָה שֶׁמֵּתוֹ מֻטָּל לְפָנָיו, וְאַל תִּשְׁאַל לוֹ בִשְׁעַת נִדְרוֹ, וְאַל תִּשְׁתַּדֵּל לִרְאוֹתוֹ בִשְׁעַת קַלְקָלָתוֹ:
Rabbi Shimon ben Elazar said: Do not try to appease your friend during his hour of anger; Nor comfort him at the hour while his dead still lies before him; Nor question him at the hour of his vow; Nor strive to see him in the hour of his disgrace.
It is possible that the author of the brayta distinguishes between people considering their own deeds (as Berachot 5a states, yesfashfesh bemaasav) and people considering the deeds of others, judging them and blaming them (which would be yefashfesh bemaaseihem).
Now, let us consider your three examples and see if any of involved going up to the people actually suffering and telling them that it was their fault.
The destruction of the first Temple? Because of idolatry, sexual immorality and murder.
How many years after the destruction of the First Temple was this explanation offered? Rabbi Yochanan ben Torta, the author of this statement, was a contemporary of Rabbi Akiva, lived in the time of Bar Kochba and was one of his opponents. So much after the destruction of Shiloh and the destruction of the First Temple.
The destruction of the second Temple? Because of senseless hatred.
What about in terms of the destruction of the second temple, which Rabbi Yochanan ben Torta also mentioned? In terms of generations of Tannaim, the first generation was Rabbi Yochanan ben Zakkai et al., the second generation which was between the destruction and the revolt was Rabbi Yehoshua and Rabbi Eliezer, who were teachers of Rabbi Akiva, and the third generation, around the time of the revolt, were Rabbi Akiva, Rabbi Tarfon, and so on. So Rabbi Yochanan ben Torta was not speaking to people who were in the process of being destroyed, telling them that it was all their fault. The prooftexts in the gemara are from Neviim such as Yeshaya, warning people well before the destruction of what would ensue.
Maalot, Israel, 1974, when Palestinian terrorists machine-gunned 25 children to death? Because 25 mezuzot on the school doors did not have kosher scrolls in them.
Please give an exact citation of this "comment", which shows a non-idiot commenting that this was punishment for this sin. It is indeed a matter of halachic debate whether a school, which is not a residence, even requires a mezuza. So they put some up, didn't realize that some were pasul, and the penalty was death? The school administrators sinned and the children were punished?
From what I was able to find from some Internet searches, it was 22 or 21 children, corresponding to what someone claimed (without publishing pictures to prove it) were 21 invalid mezuzot of all the mezuzot in the school. And the student branch of the Lubavitch movement issued a flyer which said that the homes (rather than the school) of most of the hostages had invalid mezuzot.
A kosher mezuzah on your door posts not only makes your house an abode for G-dliness, but is also your security measure even after you have left home for the day. And since all Jews are one large body, it increases the security of the entire Jewish nation. Due to the fact that most of the mezuzot in the homes of hostages, upon examination, were found to be defective, improperly placed or not on every door post, all Jews should check their mezuzot immediately.
That wasn't directed towards the administration of the school. It wasn't directed at the parents of the murdered children. It was directed at klal Yisrael, to learn from the incident.
It also didn't say that it was punishment for the sin of having improper mezuzot. Rather, it was saying that they had lacked the protection that a kosher mezuza would have afforded them.