If there is no agency for sin, why was King David punished for sending people out to conduct a (forbidden) census? (Explanation of agency: The Talmud says "ein sheliach l'dvar averia," which means, practically speaking, that if you tell someone to eat non-kosher food, the sin is on the person who eats the food, not on you.)
Possibly it's an issue of hora'as sha'ah. See ... all of maseches Horayos for detailed discussion on how Beis Din handles broadcasting improper halachic rulings that cause the public to commit an aveirah.
"Ein sheliach" works potentially in two different ways - 1) divrei harav vidivrei hatalmid, and 2) Chazal not giving the capacity for shlichus in the case of an aveirah.
- Since he was operating in position of authority more so than an average individual, he was held responsible for the command. Disobeying a direct order from the king may make you Chayiv Misa - see Shmuel 1 where people disobeying Shaul are killed - most of those were considered legally justified. That being the case, people are compelled to engage in this impermissable behavior, since the alternative is dying. So "divrei harav vidivrei hatalmid, divrei mi shomin?" wouldn't shield Dovid from culpability in this case. That potentially puts Dovid in the position of machti es harabim on top of being responsible for the aveirah being committed.
- This may not be a case of shlichus anyhow - he was punished for issuing the command to count (over Yo'av's objections), not the act of counting itself. Also, the whole story is prefaced by either Hashem (in shmuel 2 24:1) or the satan (in divrei hayamim 1 21:1) inspiring Dovid to act. Dovid says he has sinned, not the navi Gad. Hashem merely gives Dovid a choice of punishments but doesn't accuse him of wrongdoing. In divrei Hayamim, it inverts the order and says Hashem was mad BECAUSE of the census, but still doesn't tell Dovid that he did wrong.
Practically speaking, since this was a punishment from Hashem, it's in His hands to determine guilt. This is clearly an exception to whatever other rules we think may apply.