Both God and Satan incited David to number Israel. It specifically says that God did in 2 Samuel 24:1, but it also says that Satan moved David to number Israel in 1 Chronicles 21:1.
God did 2 Samuel 24:1, "Now again the anger of the Lord burned against Israel, and it incited David against them to say, "Go, number Israel and Judah."
Satan did 1 Chronicles 21:1, "Then Satan stood up against Israel and moved David to number Israel."
David sinned 2 Samuel 24:10, "Now David’s heart troubled him after he had numbered the people. So David said to the Lord, 'I have sinned greatly in what I have done. But now, O Lord, please take away the iniquity of Your servant, for I have acted very foolishly.'"
Is this a contradiction? Not at all. In 2 Samuel 24:1, God incited David to number Israel because God was angry with David. Yet, David sinned in doing it. Ultimately, God wanted to teach David not to trust in his number of fighting men, but to trust in Him. So, He moved to let David count the fighting men of Israel. He used Satan to do it which is why in 1 Chronicles 21:1, it says Satan moved David to count the men. Both are true. God most probably either sent Satan or allowed Satan to incite David. But, how can God send Satan to do a job and yet God is not responsible for the sin? Simple.
God's authority extends even over Satan. God can use Satan to accomplish His ultimate will by simply giving permission to Satan to do that which Satan already desires to do. We see this in the crucifixion of Christ where evil men brought Jesus to death. Yet, at the same time, it was the predetermined plan of God that this be done.
"For truly in this city there were gathered together against Your holy servant Jesus, whom You anointed, both Herod and Pontius Pilate, along with the Gentiles and the peoples of Israel, 28 to do whatever Your hand and Your purpose predestined to occur," (Acts 4:27-28).
Furthermore, we see in Job that God allowed Satan to test Job and demonstrate Job's character (Job 1:8-13). We see in John 13:25-27 that Satan entered into Judas to betray Jesus, but it was the plan of God that Jesus be betrayed as Acts 4:27-28 above tells us.
God allows the evil one to work His evil yet that word is ultimately used for the glory of God. All this is done without God sinning and it demonstrates God's absolute sovereignty over all creation.
Why would God punish Israel for David's sin?
We see that after David numbered Israel, that the Lord came to David's seer and told him to tell David that there would be a punishment of a famine in the land for seven years, fleeing from the enemies for three months, or three days of pestilence (2 Sam. 24:11-13). David had to choose, so David left that up to God. so, God sent a pestilence on the land and 70,000 people died (2 Sam. 24:15). Why would God do this to Israel when it was David who sinned?
First of all, no one is innocent before God (Rom. 3:23; Eph. 2:3). Second, "the anger of the Lord burned against Israel and it incited David to number Israel," (2 Sam. 24:1). So, Israel was already guilty before God, though the text does not specify why - it might have something to do with 2 Sam. 21:1-2. In this, we can see that we don't have all the facts. Third, there is a doctrine called federal headship. This is the teaching that the male represents the descendants (Heb. 7:7-10; 1 Cor. 15:22). It could be that David was representing his people as any leader would and was possibly motivated by pride. And so they suffered because of the actions of their leader.
Though we are not exactly sure why God let judgment fall upon Israel for David's sin, we can see that Israel was already guilty before God (2 Sam. 24:1) and that combined with the leadership of David, resulted in the judgment that came upon them all (2 Sam. 24:11-13).