To supplement AviD's answer, also note that many instances of punishment in the Bible actually amount to letting things take their natural course. Indeed, for this reason the expression often used is that G-d "hides His face."
Consider your example, of Achan's sin and its consequences at the battle of Ai. Why indeed are Joshua and the elders going to pieces over one lost skirmish, and thirty-six casualties out of a force of two or three thousand soldiers? Any good general would probably remain stoic in the face of a much higher loss rate.
But the reason was that they knew that the conquest of the land of Canaan was not to be a regular military campaign following the usual laws of probability. If that were the case, then indeed they wouldn't stand a chance; "you [the Jews] are strong, but they [the Canaanites] are stronger than you" (Rashi to Deut. 11:23). So it would require divine aid every step of the way. And to deserve such supernatural aid would require them to maintain a super standard of behavior, such that out of a nation of millions, not one person would take something to which he or she is not entitled. (Bear in mind, too, that we're not even talking about stealing someone else's property; Achan's sin was taking property that was "banned" and "accursed" - i.e., slated for destruction.) So if that standard can't be upheld - and it doesn't matter whether it's one person or a thousand who are violating it, because it is a corporate national responsibility - then things revert to their normal course. And the normal course is indeed that a weaker army, not on its home turf, is going to lose. That's what upset the leaders so much: the realization that if the Jews can depend only on their own military might, then it's not just the one city of Ai that might hold out - the whole enterprise of conquering the Land is bound to fail.
To take another example, much of the Bible is full of prophetic warnings that the sinful behavior of the Jewish people (or segments thereof) is going to lead to foreign conquest, exile and destruction. Here, too, consider: is that a "punishment" or simply what's to be expected geopolitically? A small country with a largely agricultural population, sandwiched between two powerful empires and a bridge between three continents, is naturally going to be prey for one side or the other, if not both in a pincer movement. What kept Israel as an independent state for 800+ years - from Joshua's conquest to the Assyrian and Babylonian takeovers - was, again, G-d's protection. And again, for them to deserve that - to buck the history of every other nation in the world - required them to act as a nation that indeed is distinct from all of those other nations, and to make sure that every member of that "corporation" is aware of his or her duties and upholds them.