Shekalim

Shemot 30:11, “When you take the sum of the children of Israel according to their numbers, let each one give to the Lord a ransom (substitute) for his soul when they are counted; then there will be no plague among them when they are counted”: 

Rashi explains that the shekels are counted to know their number. 

Shemot 30:15, “The rich shall give no more, and the poor shall give no less than half a shekel, with which to give the offering to the Lord, to atone for your souls.”

Rashi explains that the shekels atone to not be struck by a plague because of the counting.

So did they count the coins to avoid a plague, or did they count the people and need atonement?

Answer: Both

There was no atonement on the individual level. The half-shekel was communal atonement showing the unity of Israel, all giving the same amount, and each jew a half of a whole. They could not count each person, because there was no individual atonement. So they needed to count the coins to avoid the plague.

But when they counted the coins, the purpose was to know the whole number of Israel, not to know the whole number of coins, as Rashi says, “thereby you will know their number. ” They avoided individual responsibility by counting the coins, but they still had communal responsibility by knowing the whole number of Israel. For this, they had communal atonement through the unity of Israel of the coins.

As such, the first verse above is in the singular, each person giving a ransom, a substitute. And since they counted the substitute coins, the verse says, and there will be no plague. The second verse, on the other hand, talks about their unity and provides atonement for their souls, plural.