You all know the allegory about the boat for “kol Yisroel areivim zeh l’zeh,” right? We have to worry about what other people are doing for the same reason we have to worry if we’re in a boat and someone is drilling a hole under their seat. If water comes into the boat through their hole, the boat sinks and we all drown. And so too, if another person is doing aveiros, we’ll all suffer.
After all, if one Belgian drills a hole under their seat, the boat sinks and they all drown.
The world called the German’s draconian measures “The rape of Belgium,” and it inspired propaganda posters like these.
Were the Germans wrong for subjecting the Belgians to collective punishment for individual's actions? If you think they were - as most people did and do - then so too, God subjecting Klal Yisroel to collective punishment for individual's aveiros.