The statement 'infidelity is caused by problems in the marriage' is a bit like saying 'Vomiting is caused by too much alcohol' and is as reductionist as that absurd statement. It might be one of the causes, but if a person vomits and hasn't been drinking any alcohol, where does that leave us? 
I've probably come across more affairs of the type Cogito is describing; people who were happy at home and had no plans to leave or even make changes to their set-ups, but who had rubbish boundaries when someone else showed an interest. I think for the most part, the people I knew started off their little adventures thinking they could compartmentalise and put the affair and the marriage into discrete boxes, but most of the time it turned out they were rubbish at it.
You see, these guys and gals weren't practised deceivers. So despite all good intentions, they started acting like arses at home, found the deceit too stressful, didn't cope well with the demands being placed on them by two people and as an observer looking on, it was like watching a person completely dissemble. Their work suffered (hence my involvement), they developed the memory retention of a goldfish and so in most cases, they got found out.
The trouble is, the propoganda of the 'Problems....affair' is so strong in our society, that even the people who weren't unhappy start believing that they must have been! This sort of self-excusing probably goes on more in people who have on the surface, always done the 'right things' in life. Whereas the people who make a habit of cheating and doing unethical things are probably a bit more self-aware and know that they can't kid a kidder (themselves.)
With other types of affairs where unhappiness is more obvious (and I've known a few) I still don't think it was the only cause, although of course it must have been a factor. But I have a friend who's in a very unhappy marriage, who's had loads of opportunities to cheat without any real risk of being caught (and one man in particular would have been much better for her IMO than her wretched husband) but she just won't do it. I once had a male work colleague who was in exactly the same boat as her and he wouldn't cheat either, despite other women making it quite clear to him they'd be up for some fun.
Really, this is down to the individual isn't it? That's what must make the difference, not the state of the relationship.