I think you can make a distinction between people having affairs who would be devastated if they were found out, and those who (consciously or subconsciously) want to be found out, because they want the issues within their marriage to be brought to a head and ultimately resolved.
I had an affair for a few months with a MM (big regret). I wasn't married. It was a very 'casual' affair in the sense that we only spent a few hours together in the week and didn't make any plans for the relationship having a future. We didn't even really have any depth to our relationship; didn't have much in common, other than a shared sense of humour and sexual compatibility, enjoying each other's company etc.
Then, out of the blue, he told his wife. We'd never discussed such a move and I was shocked. In hindsight, though, I can see why he did it. He'd started the affair with me because he was feeling neglected and ignored. At some level he expected her to notice there was a problem and react accordingly, ie pay him more attention. She didn't. Once she found out she was desperate to keep the marriage going and for them to re-engage in every way that had previously been lacking, which was of course his whole aim in the first place.
During the affair I actually posted on MN (different NN) about how I didn't see the harm if we never got found out. At the time I truly believed that applied to my situation. As far as I was concerned, I was happy with a PT relationship, liked my independence and having my own space, but also enjoyed having a brief 'adult interlude' during the week that gave me a break from the usual routine of being a single mum who doesn't get out much. Also, from MM's POV I thought it worked in the sense that he could get (from me) what he felt was missing in his own life without any threat to his family. However he didn't want to get what was missing from me, he wanted to get it (back) from his wife. This was where it got fucked up and people ended up getting seriously emotionally hurt.
I feel awful about it now and know I manifested not only a terrible lack of perspective but also a glaring lack of self-respect. MM could have resolved all his problems by a dedicated attempt to communicate with his wife and saved a lot of pain all round. I hate the fact that I participated in what was essentially just a sordid cry for attention. Some people who embark on affairs however simply don't have this aim, either they have given up on their marriage and are content to seek satisfaction elsewhere, or they see no viable option to resolve their marital problems, eg (perhaps) the poster upthread who has an asexual husband. There are just so many variables in motivations of all participants.