I suggest people wander for a variety of reasons, rarely as simplistic as has been mentioned.
First there is the genetic drive of men spreading their genes, women are on the hunt for better genes.
Boredom, in all its aspects. Within relationships and beyond. Variety is the spice of life. An opportunity strikes.
Partner performance issues and disinterest.
People marry for many different reasons. They fall in lust, seek to escape a parental household, it's the cultural thing to do, status, and so forth, any of which can diminish as a driving force over time.
Using sex as a cure for one own's insecurities and sense of inadequacies having nothing to do with sex or the health of their relationship with their mate. Like aging and thinking they can feel more youthful by having sex with another or multiple partners, younger partners.
The thrill factor of possibly getting caught.
Sexual activities they would never do with their mate.
Peer pressure, locker room or gym talk. (You think your wife is doing pilates?)
Change in sexual orientation, not necessarily from straight or gay to the opposite.
Availability. Where I live there is a massive surplus of single, widowed and divorced women over age 30, and a massive shortage of available capable heterosexual men. A formula for wandering men. (Within weeks of my first wife's passing, I couldn't believe how often I was propositioned by many attractive women. And it left me more depressed.)
The possible reasons are endless.
A fellow I knew only cheated on his wife with ugly women. If caught he didn't want his wife to think he was no longer attracted to her. Another fellow was attracted to very large women, his wife was slender and petite. How many people do you know who barely tolerate their spouses, even hate them, but maintain their relationships because they cannot afford not to, or for "the sake of the children," or habit and an undefined comfort level of not coming home to an empty abode, and so on? As people mature and age, sexual compatibility may fade, while every other aspect of their relationship may improve, and for the sake of sanity they make an arrangement, a convenience. I know a couple who are successful business partners, they sleep in separate bedrooms, and they each have lovers. Not for me to judge.
Sexual behavior is very complex at times. And more than some people may not understand their own motivations. Why do any think they can simply explain what others cannot self define?
Paul Newman, when asked if he ever strayed from his wife, Joanne Woodward, responded "Why go out for hamburger when I have steak at home?" Not everyone has steak at home. Some people have steak at home and crave hamburger.