This objection is actually brought up in the discourse between King Aila and Rishi Kashyap.
Aila says,
'If chastisement touches all viz., the honest and the wicked alike, in
consequence of the sins perpetrated by the sinful, why should men, in
that case, do acts that are good? Indeed, why should they not perform
wicked acts?'
And Kashyapa responds,
Kasyapa said, 'By avoiding all connection with the sinful, one becomes
pure and stainless. In consequence, however, of their being mixed with
the sinful, the sinless are overtaken by chastisement. Wood that is
wet, if mixed with wood that is dry, is consumed by fire in
consequence of such co-existence. The sinless, therefore, should never
mingle with the sinful.'
So because the good people in the country are in contact with the evil people (since when you live in a country, you are forced to interact with everyone), they have also sinned, and so they will also be punished for their sins.
So in reality, each individual sinner is being punished for their deeds and their association with sinners, and coincidentally the whole country gets punished.
So there is no violation of the law of karma that says only individuals get punished and rewarded for their own actions, and so everything is fair.