There are five stages in any gold farming operation:
First, gathering. This is done via a small army of automated programs. In other words, bots. These bots are usually hunters, and are equipped with easily obtainable loot, like bind-on-equip rare items. These bots are then sent to work on carefully selected areas of the world, where there's appropiate prey that can be safely killed with the limited intelligence of the bot, yet drop good enough loot to be sold. Popular places for bots are Felwood, Burning Steppes, Blasted Lands, Deadwind Pass, and pretty much any area where there's high-level non-elite mobs or easy elite mobs. Hunters are the most popular bot type because of their pet and Feign Death. The pet keeps the bot itself from any harm, and it can Feign Death when necessary to save it's life.
The gatherer bots generally don't do a very good job at impersonating real players. They rarely responed to interference, unless the bot is directly attacked. While the bot is clumsy and can be easily dispatched by a human player, attacking the bots is in general a futile attempt. Blizzard has a hard time detecting these bots, because they technically do nothing that could automatically be monitored and detected. Vigilante players can hunt the bots and even make the bot lose gold instead of gaining it. This is accomplished by tagging the target mobs before the bot can hit them, causing the bot to gain no benefit from killing that mob. Unfortunately, the only loss at this case is the wasted use of ammo, which is quite cheap. Another trick that can be used is to either draw additional mobs to the bot, or weaken the bot by attacking it so that the mob it is fighting can finish it off. This results in repair costs, and if done enough, can force the bot to return to a city to repair. However, even this effect is neglible. Why? While it does make the bot less efficient, it is still relentless when compared to human players. No human will harass the bot 24 hours a day, 7 days a week. When the human gets tired, the bot will resume making pure profit. In addition, there are usuall multiple bots scattered around the world, so distrupting one will only make a slight dent in profit. Reporting a bot can shut it down altogether, but a smart goldfarmer uses multiple bots to make sure that the gold keeps flowing. In addition, Blizzard seems to favor banning lots of bots at once, instead of banning them one by one.
Secondly, there's storage. After the gold has been gathered, either by farming or selling the gathered items, it needs to be stored to wait for potential buyers. A naive way to detect storage accounts would be to monitor the amount of gold in the account. This is easily thwarted by distributing the gold evenly across multiple accounts. In addition, this reduces potential loss if Blizzard does shut down one of the storage accounts. A better way to detect storage accounts is to follow the money. Unlike normal exchanges between players, the flow of gold is overwhelmingly one-way. Farmer bots get gold and send it to storage accounts. Storage accounts then send it onwards. While the goldfarming operation might try to "launder" the gold by sending it through multiple accounts, the general flow still remains. If Blizzard were to employ a retired financial crime investigator, for example, methods could be devised to detect these flows of gold automatically.
Third, there's marketing. Once the gold is collected, the goldfarming operation needs to find buyers. This is mostly done with website ads. The websites are beyond Blizzard's control, so they can do little to stop this. There are plenty of ISPs that do not honor takedown requests from American companies such as Blizzard. However, some marketing is done in-game by throwaway accounts. Bots spamming advertisements in-game are easily detected. Not only they use predetermined phrases, they also tend to annoy a lot of legit players, which in turn results in the advertisement bots getting banned quickly. However, the profit margins of gold farmers allow them to just buy (or otherwise acquire) a new license and resume advertising. Advertising bots do not even try to hide themselves.
The fourth phase is making the sale. This is overwhelmingly done via the goldfarmer's website, so there's little Blizzard or individual players can do to stop it from happening.
Finally, there's delivery. While the goldfarmers might try to "launder" the gold or items by funneling them through several accounts, the buyer still needs to receive an unusual amount of goods. Large transfers of gold can be detected easily, so a smart goldfarmer will probably use several accounts to transfer the merchandise in small amounts. Still, the end result is the same. A certain player received a sudden influx of money. And this is what Blizzard can easily detect automatically and start to follow the flow of gold back to it's source. However, this process is somewhat slow, because verifying each chain of the link requires some manual labor. Blizzard does not want the bad publicity of accidentally banning large amounts of innocent players, who might have bought items in-game from the farmers, not knowing that they were doing so. Eventually, Blizzard will map the whole network of the goldfarmer and then ban all of the farmer's accounts in one sweep.
It has been argued by TotalBiscuit and others that banning accounts in batches is not enough. While Blizzard tracks down the farmer's network, he can continue making profit. So when Blizzard finally closes down his operation, he can simply start over with the profit he has already gained. On the other hand, banning farmer bots quickly will reduce the time they will generate merchandise for the farmer. However, this leaves the rest of the farmer's "network" intact. While Blizzard can obviously follow the money from the banned account and track down at least some other accounts, it will not shut down the farmer's operation altogether. All they have to do is to acquire some more licenses and set up more bots. In addition, banning only certain bots will alert the goldfarmer that Blizzard has caught up to them. Unless the gold farmer itself is caught by law enforcement, banning individual bots is a hindrance at best.