They buy and sell space to from other ad networks, to the extend that some sites have no idea what sorts of ads will be shown. Then when one ad gets obnoxious and the site gets complaints, they try to trace it back and discover that the transaction went through four people, for instance.
Most ad networks take very hard lines against problematic ads because sites and networks can and do turn off advertising from whole vendors. But all it takes is one network to sell to someone dodgy, even by accident, and for a short time something nefarious can be on even the most blue-ribbon site.
Wade.