Only Hashem has the authority to call a census which is to be followed by a census tax as required in Shmot/Exodus.
Israel became a patriotic supporter of David's ambition and usurpation of Hashem's authority.
Don't forget 1 Samuel 8. It was then that Israel wanted to be like the other nations and have an king. Hashem told Shmuel to tell the people that they have rejected their one and only King, and that the king would oppress the people and bring them war and disaster. But Israel would not listen.
Again this time, they did not want to be constrained that only Hashem could authorize a census and only Hashem could authorize a war.
There is similarity to Shaul שאול going ahead with the offering without waiting for Shmuel.
However David's was a more extreme case.
If you combine 2 Samuel 24 with 1 Chronicles 21, you will find that Hashem Himself became Satan against David. Some people cannot bear the thought asking how could Almighty Hashem be Satan. So they say well actually Hashem was represented by a Satan.
Oh dear some of us have succumb to accepting the Christian definition of a demonic Satan.
Remember in Bamidbar/Numbers 22:22
- Almighty Hashem sent His MLAKh to be Satan against Bilam:
- וַיִּתְיַצֵּב מַלְאַךְ יי בַּדֶּרֶךְ לְשָׂטָן לוֹ
- placed mlakh Hashem in the way to satan him.
For Hashem to send His Satan at you, is a very critical affair. And if Hashem sends Himself in direct command of Satan that is catastrophe.
Look at the catastrophic life of David and his household. Among which
- Batsheva. He kills a warrior who is loyal to David and Israel in order to get his wife.
- His militia risked their lives to bring him water from his hometown. He megalomaniacally disappoints them by pouring the water he pines for away.
- He named his son AvShalom father of peace. Who then carries out a coup against him.
- While on his deathbed he instructs his son Shlomo to murder the righteous general Yoav. Yoav has been the one discouraging and at times stopping David from acting against Hashem.
David's conceit, and Israel in their patriotic support of David in usurping the authority of Hashem.
If you read the passage just before this, David just came out of a war. So David had been conducting unauthorized warfare. It was after that war, that Hashem came to test David to call a census. The righteous general Yoav attempted to discourage David in vain. It was already in David's head to usurp the authority of Hashem.