I was wondering, throught the 2nd season he see little to no zombies on Hershel's farm except when they were drawn there by Carl's gunshot. What would keep them away? There are people and livestock all over the place that could lure a zombie to draw near. Hershel also had no defences except for barbed wire fences, which caught no zombies. This same scenario can be applied to the prison. There was people and some livestock all over and there were hoards upon hoards of zombies clawing at the fences. What kept the zombies away from Hershel's poorely defended farm and drew them to the highly fortified prison?
Luck, timing (early in the outbreak), and the location of the farm (relatively far from major towns and cities). Walkers are attracted to people and noise, and the farm had little of either. There isn't much explicit canon information to explain this, but I read the comics and watch the show obsessively, I've read some of the novels, and I'm a zombie fanatic.
The farm wasn't spared completely though - many of Herschel's family members, friends, and neighbors were in the barn as walkers, because they were bitten. There are zombies in the area, but not as many as in other places.
Also, he did have fences - lots of them, one after another, to separate the fields and pastures from one another. A herd chasing a sound would (and did) break through them eventually, but a single zombie (or small group of them) wandering aimlessly would bump into the first line of fences and wander off in another direction.
Keep in mind that Rick's group got to the farm maybe a month and a half after the outbreak started - maybe less - and left after only a few weeks (Lori wasn't visibly pregnant when they left).
Season 1 took place over the course of a few days (not including the shooting that put Rick in the hospital) - fewer days passed than there were episodes in the season; by my count, 5 days total, vs. 6 episodes. Day 1: Rick wakes up and gets to Morgan's house, sleeps there. Day 2: Rick leaves Morgan at the police station, goes to Atlanta, meets Glenn and the others, and goes to their camp, where he finds his family; they all go to sleep. Day 3: Rick, Daryl, and T-Dog go to Atlanta to look for Merle, meet the Vatos, go back to camp after dark, and find it under attack; Amy and Jim are bitten, no one sleeps. Day 4: Amy and Jim die, the group goes to the CDC, gets drunk, then showers, Shane tries to rape Lori, everyone goes to sleep. Day 5: The group escapes the CDC, Jacqui dies in the explosion, the group spends the night camping somewhere near Atlanta (the season 2 debut begins with Rick on a rooftop overlooking Atlanta the next morning, talking on his walkie-talkie). Season 2 began the day after the escape from the CDC, and ended about a month later, maybe a bit less, maybe a bit more, but they were on the farm for no less than 2-3 weeks, no more than 6 weeks - enough time for Lori to realize she was preggers, but not enough time for Shane's hair to grow back (he shaved it off the first night they were there, which was two nights after they left the CDC).
And since Rick would have died of dehydration if his coma lasted more than a week or two after the hospital was abandoned, and the hospital was abandoned shortly after Rick got there (things went bad VERY quickly, and hospitals were the first places to fall because that is where everyone who was bitten went). When Rick woke up, he had a bit of stubble, but not much - I'd guess about 2 weeks' worth by average beard-growth rates - and the lights and water were still on; so he can't have been in the hospital for more than a week or two after it fell, maybe 3 weeks total after he was shot. Finally, Shane and Lori only hooked up after the city fell, probably after they got to the quarry campsite; she probably wouldn't know she was pregnant for a month or so after conception (she'd notice she missed her period before morning sickness started happening). So they left the farm no more than 8 weeks after the outbreak began, possibly as little as 5 weeks, probably closer to 6 weeks.
By the time they reached the prison, Lori was very pregnant, and they had spent the entire winter on the road (they said so); it seemed very warm already, so it was probably mid-late spring; on the farm it seemed warm, but not terribly hot, and they were worried about it getting cold soon (the subject came up late in season 2). This suggests that they left the farm in early/mid fall (leaves were still on the trees and still green). So between the end of season 2 and the beginning of season 3, at least 4 months passed, possibly as much as 6 months. That is 4-6 months of survivors dying and coming back as zombies. 4-6 months of zombies leaving the abandoned cities and spreading slowly across the countryside. 4-6 months of zombies clumping into groups, groups merging into herds, and herds roaming around, sometimes aimlessly, sometimes chasing prey.
There were lots of zombies in the world when they reached the farm, of course, but not as many as there would be a year later. Think about season 1 - the group was camping within sight of central Atlanta, perhaps 5 miles or so outside of town, yet the first time we see a zombie enter the camp, someone says "They never make it all the way up here!" or something like that. They were only a few miles from the highest concentration of zombies in the state - there must have been hundreds of thousands (at least - probably over a million) of zombies in Atlanta by then (population of the city center = 500,000 people, but there are 5.5 million in the metro area, and the military was telling everyone to go there until the moment it fell, so there must have been millions in the city center before it fell) - but they rarely saw any of them. They could even go into the city itself for supplies and make it back safely as long as no one fired a gun and attracted a herd. Herschel's farm is much farther from major population centers, so there were far fewer zombies in the area.
And as Cvance74's answer mentioned, the stream and woods acted as natural fences as well.
As for there being more zombies at the prison, several months had passed, so there were more zombies in the world. The prison was far from the farm and presumably closer to big towns and cities (they mention Macon in particular). And large numbers of zombies only start showing up after dozens of people from Woodbury move in, which made the prison a much noisier, busier place, with much more activity to attract zombies. Several pigs in a 2 acre yard behind 2 chain link fences attract more zombies than several cows on 200 acres behind a series of wooden fences. More animal noises in a more confined area that is more exposed and visible, basically.
Moving on to the issue of herds... I'll let Sgt. Abraham Ford explain (I edited out the naughty words).
Basically, walkers can't think at all, aside from the brain activity required to see/hear/detect prey (prey = living or recently killed people/animals), follow it, grab it, and eat it. Usually they ignore everything but potential food - if it isn't prey, or something that might be prey, they don't even notice it. If no such prey is around, they either hang out waiting for prey, or they wander aimlessly looking for prey.
But sometimes, one zombie will see another zombie walking, assume that it is chasing prey, and start following it. The walking zombie might indeed be chasing something, or following a sound it heard; but it might just be wandering aimlessly - it doesn't matter. Then another zombie sees the first two walking, assumes that they are following prey, and starts following them. They pass another zombie, he assumes they are chasing something, and he starts walking too... This goes on and on, and eventually you have a herd walking along chasing nothing, or maybe chasing a sound none of them remember hearing. They might keep walking forever - each one assuming that the others are following prey. Eventually, they'll probably stumble across some sort of prey, totally by accident.
Alternatively (this paragraph has its basis in both The Walking Dead AND the books World War Z and The Zombie Survival Guide), one zombie hears a scream (or a gunshot, or a car, or whatever). He moans, and starts walking towards it. Half a mile away, a second zombie hears the first zombie's moan, moans himself, and starts walking towards the first moan. A quarter mile away, 2 more zombies hear the second zombie, the moan, and they follow the others... and so on and so on, until again, you end up with every zombie for 100 miles around walking in the same direction because of a sound only one of them heard (but even he doesn't remember hearing it).
Or a zombie might see a car or a person. He starts to follow the prey, but the car/person gets farther and farther ahead, and is soon out of sight. The zombie will keep walking in the direction he last saw the prey going. Other zombies (who didn't see the prey) spot the zombie walking along, and they join him. As they pass other zombies, the group grows, and again, you get a herd chasing prey that none of them remember seeing.
This is what happened with the herd that attacked the farm. A few zombies saw a helicopter and started chasing it. Being a helicopter, it was moving so fast that it vanished out of sight very quickly, of course, but zombies are REALLY stupid, so they kept walking in the direction they last saw the helicopter going. Other zombies saw this group walking, assumed that they were heading towards food, and joined the group. They all forgot what they were chasing, but each zombie saw the rest of its herd moving and assumed that the other zombies knew there was food ahead, and this kept all of them moving in the same direction for days. Then, at exactly the right - or wrong - time, Carl fired his gun. The herd heard the shot and changed course - they turned and went towards the sound of the gunshot. If Carl hadn't fired the gun, they would have walked right past the farm. As I said, the herd attacking the farm was pure (bad) luck. And the fact that no herds had attacked it before that was pure (good) luck.
There is no "herd mentality", because there is no "mentality" of any kind - zombies are too stupid for that - but there is something you might call a "herd dynamic". They aren't thinking, really, just reacting, and they don't enjoy each other's company or make decisions. They probably don't even notice other zombies at all in other situations (note how they walk into each other when there is a big group in one spot not going anywhere). But when one zombie sees another walking in a specific direction, sometimes he starts following; not because he's looking to make friends, but because he assumes there might be food ahead. Once a group or a herd forms and is moving along, unless they hear or see prey, each member of the herd keeps walking because the others are walking, so each assumes the others are chasing dinner.
Part of the subtext of your question relates to the intelligence of zombies; you seem to be dangerously close to overestimating what the zombie brain is capable of. They are stupider than the stupidest person who ever lived. They don't think - they are single-minded (if it even makes sense to talk about zombies having "minds" of any kind), and they can only sense prey, chase it, grab it, bite it, and eat it.
In fact, zombies are so single-minded that even when they are in the middle of eating someone they killed 5 minutes earlier, if another person walks by, they will abandon their meal and chase after the new prey. Since they are dead, they can't digest what they ear, and eating doesn't benefit them in any way. A zombie is basically a vehicle the virus uses to infect new hosts. It makes the zombie feel constant hunger, which makes the zombie bite people, which spreads the virus to the bitten person, and so on. So it is in the virus' best interests to make the zombie host bite people, but NOT let them eat the entire body. The virus only benefits when the bitten person is left more or less intact, so they can turn and begin biting people as well, thereby spreading the virus to new hosts. When a zombie bites someone, and the bitten person is completely eaten, the virus doesn't benefit at all.
I don't even like using the word "assume" to describe what is going on in zombies' heads, because they're too stupid to even assume anything. They just feel hungry all the time and automatically respond to anything that might get them closer to food.
To show just how stupid they are, imagine a canyon a mile deep and 50 feet across. You are on one side, and a herd of 1,000 zombies is on the other...
One of the zombies notices you, and walks towards you. He falls into the canyon and is smashed to bits at the bottom. A second zombie sees you, and walks towards you; fall, SPLAT. Then a third - SPLAT. This will keep going on until there are no more zombies left. Even zombie #1,000, who just saw 999 others try to get to you and fail miserably, will learn nothing from the gruesome fates of the 999 who went before him. He won't try anything different, or realize he can't reach you, or lose interest - he will march right off the edge of the cliff and fall to his (final, permanent) death, just like all the others.
They can't learn. They can't think. They can't adapt. They can't plan. They can't make decisions. They can't turn doorknobs or open windows. They can't climb. Even stairs are difficult for them to navigate - they can crawl up slowly or tumble down quickly, but they are so stupid that even the simple act of lifting a foot, placing it on a step, pulling themselves up, and repeating the process is too much for them to handle. They can only stand, sit, lay, crawl, stumble, grab, claw, pull, bite, chew, and swallow; if they have intact eyes, ears, and noses, they can see, hear, and smell. But they are blind, deaf, and... unsmelling(?) of anything that doesn't suggest the presence of prey.
Note: In the first two episodes of season 1 we saw zombies do three things that infuriated zombie fanatics like myself around the world - Morgan's zombified wife turning a door knob, a zombified child picking up a teddy bear, and one of the zombies in the herd outside the department store using a rock to break a glass door. These things would NEVER happen in the comics, because Kirkman is a zombie purist. I was also annoyed by the walker sitting down on the bus (unless that is where he died, he would have gotten off the bus and/or stood up, and since zombies don't care about comfort, if he sat down again it would have been on the floor - they don't know what chairs are), and by the zombie trying to climb the fire escape ladder (they can't climb and don't know what ladders are), but at least the ladder zombie failed before he got off the ground. We zombie freaks take these things very seriously. I'll stop now, lest I turn this into a rant.
The creek or whatever was surrounding the farm trapped some of the Walkers in the thick deep mud too.
I think it was because Hershel had walkers in his barn. And after Shane let them out they would find them around the farm and In the episode where Shane is going to get killed right after Shane got shot there was a camera moment where the walkers where walking in one direction and heard the gun shot and then went to see what the noise was. I also believe it was that is why there where walkers in the barn. TO KEEP WALKERS AWAY.
I think it was the fact that no one ever really shot a gun and when ever there was walkers they where able to contain them. Also Hershel had walkers in the barn and after Shane killed them a episode later everything went down so maybe that's why.
".. turning a doorknob.. picking up a teddy bear.. and using a rock to break a glass door. These things would NEVER happen in the comics, because Kirkman is a zombie purist."
ABSOLUTELY! And those Same Exact Scenes Bothered me immensely as well! And yes yes I do realize this is all based on a fantasy-reality, but the difference between an Ok-Story and a Good or even A Great Story is a consistency throughout. Sounds pretty basic, but it's something that was lacking in the show in the very beginning.
Also I'm pretty sure you left out that super-zombie (occurred in the same rock-zombie episode) that pretty easily Scaled a fence! Took place when they were going for the vehicles to make their final escape from that department store. He just went up and over it!- As if in his "Living Days" he was an athlete of skill and quick agility of which parts Still Remained Within him! Uh. No. I don't think That was zombie-certified.
* Also when that first glass partition did finally break... I'm pretty sure I heard a zombie SAY something akin to "Yes!" It's been a while so I'm not sure Which zombie gurgles out the "Yes! or Yay!"... it could have been that same improvising-zombie with the rock in his hand like a Tool.
Incredibly un-zombie-like! Did anyone else hear that as well? Also... When they were stuck on the concrete highway as the herd was or had make their way through.. didn't one of the Walkers go up the MotorHome's stairs and into the motorhome itself... and after hearing Andrea making noise in that tiny bathroom was it, didn't that zombie Grab The Door Handle in his attempt to get at her?
Then again ALL of the Zombie-Fouls I remember were done in The Pilot or Second Episodes.. and so although Annoyed by these errors I've viewed them as their learning curve. I would have thought such details would have been on the TOP of their Do-s and Don'ts but perhaps production and network money matters and committees just may have been the True cause, not allowing for 100% diligence on zombie can and can'ts. IDK.. But in the episodes that followed I was Indeed Very Pleased to see that Although zombies themselves are unable to Learn by their mistakes - the writers themselves can. and did.
Did anyone else pick up on Other Zombie-Errors?
Perhaps ones not mentioned above or here below in the Comments sections?
I think most of us would really enjoy hearing about them.. even ones that are on-the-fence so to speak. peace. G'Nite.. and don't let the dead-ones-bite! :)