I think it depends a lot of the reasoning for having the affair. I do this it's a very common phenomenon and this is how it works:
The person who decides to cheat is motivated by some void inside themselves, some level of self-loathing that makes ego kibbles of someone else's attention appealing.
Quite often the people most willing to give ego kibbles and endless attention to someone married, are themselves a complete fuck up with similar self-loathing.
The fact that the affair partner is sort of "beneath" them, can have an added effect of making the cheater feel good about themselves.
I have seen a lot of men who had affairs behind the backs of great women, with affair partners who were clearly less successful, less physically attractive, less appealing by age, less good of character. I have also seen a lot of cases where the affair partner has some kind of problems: alcoholism, personality disorders, anxious attachment.
Basically anything that makes them a bit desperate and shower the cheater in admiration so their void can be filled and they can feel loved and appreciated and special.
Often in these cases the affair partner is someone the cheater would never look at as a potential spouse or serious relationship, but they can become almost addicted to the needs the person meets.
My husband cheated with a woman from work, 20 years my senior, looked like a man, very dramatic, chaotic and with a serious drinking problem. No one could understand it, but I think her being a complete mess was the appeal.
Of course there are some affairs where two people just meet, get on and boundaries are crossed and these are probably people who just happened to meet when they were attached to others