I think there are many different types of personality who have affairs for a myriad of reasons. Given it's so prevalent I'd go as far as to say it's a fairly natural behaviour. That's not a moral judgement. I'm not saying it's ok because it's natural anymore than I'm saying it's ok to punch someone when you're angry, which is also a natural behaviour but one we try to prevent through socialisation and law.
Truth is that a great many people, in the right 'perfect storm' of circumstances, often find themselves behaving in ways they have previously loudly condemned. It's not just callous predatory types. Good people can behave in shitty ways. Likewise, some pretty evil shits have remained steadfastly faithful!
In my observations I'd say a lot of affairs start because the affair partners make each other feel good about themselves in ways they're not getting from other sources, be that their spouses, their job or whatever. Feeling desired and special is a powerful aphrodisiac and secrecy feeds it. (Which is why so many affairs crumble once they're out in the open.)
From the successful couples Ive known I'd say the secret to affair-proofing a relationship is for both parties to recognise it could happen to them too.
This starts with recognising that long-term romantic/sexual relationships are one of the most conditional relationship types out there and therefore require a lot of input from both to keep them in tip-top condition. This includes a responsibility for each person to be the best person they can be in their own right and not sacrifice everything to the relationship (something women are particularly prone to), while recognising that they have to facilitate this for the other party too (something men can be prone to neglecting). This really helps foster respect for each other, keeps a spark of interest, and promotes a sense of partnership for the areas where the two people come together for to achieve (e.g. parenting). If you get the balance right, it becomes an easy partnership. It shouldn't leave anyone feeling like they're living in a perpetual state of hyper vigilance. Although it does rely on both parties being basically ordinary decent people I guess. Abusive types can't do that.
You also have to recognise the first signs of vulnerability - boredom, particularly - and be very careful who you socialise with or talk to when feeling like that. The first steps to an affair are usually imperceptible - an innocent reply to a text but one that wasn't really necessary, staying longer than needed to help out with something and simply chatting afterwards. It's how emotional affairs start. If you recognise it early you can stop it and it's much easier then than it is when you've gone on a works night out and had a few drinks and that colleague you've been helping out suggests going on to another bar. A lot of people kid themselves they would never cheat but what's the harm in just having an extra drink in the company of a colleague. One turns into a few, inhibitions are lowered and so on. Knowing you could be fallible means you have the awareness and therefore the opportunity walk away before crossing a line.
I think most OW/OM are flawed (as are all of us in different ways) rather than nasty people. I think many cheaters are too, but it's only cheaters who have a responsibility to the betrayed partner in my view. Unless thry also hapown to be a friend/family member etc.