I've switched every few years for the last 8 or 9 years. I'm on my 4th main job, though I did some consulting in between. Each time I moved it wasn't because I was unhappy but because something else came up - I've always been careful to choose the place I work at. Meaning, when you interview, it's a two-way process: they're not JUST going after you, but you need to decide if you like them.
I helped start the company I'm at now and I love it. I've worked with most everyone for at least 3 years now, some almost 6 years. We're all really good guys, love programming, etc. etc. Since I love the work and the pay is good I wouldn't even consider switching.
On the other hand, there could be a number of reasons for someone to switch. Switching can often mean higher pay, especially in your first few years programming. You learn the most during this time and your current employer may not be willing to boost your pay accordingly. But if you're really happy, it may not matter as much - I'd rather enjoy what I was doing and make a few grand less than work with people or on projects that I didn't like.
If you switch TOO often, it looks bad on your resume. Unless you're a consultant, many employers don't want to see you switching every six months or a year. It takes at least 3 months to get settled in at a company and they'll spend the next 6 months or so making up the money they spent training you and getting you settled before they start making money off of you. If you leave too soon, it will hurt them.
Then again, you may be at a company that you like and working with people that you like and even making good money, but the work itself isn't that satisfying. Maybe you're just supporting an old app and not doing any "fun" or "new" programming. If you're aching to advance, your only chance might be to switch, even if you don't want to. My first job was like that - doing VB3 programming on a large application (100+ forms, each hitting the Windows limits for the number of controls per form, etc. etc.). It was GREAT experience at learning VB, Windows, DataBases, etc. etc. I loved the guys I worked with, I got to go to conferences for free, training was free, good salary and bonuses and lots of raises (about 6% every six months - I advanced quickly). But in the end, after about 2.5 years I was just getting bored. The work was too easy and my boss didn't want to find any new contracts or hire any new people. I felt *really* bad when I left since I didn't have any bad feelings. But I knew if I stayed, I'd be doing VB3 for another 5 or 10 years just supporting that app. Making a move worked out great for me, but it might not be right for everyone.
Anyway, that's my long ramble for the night
-nerseus