I agree with dashingscorpio, and the relationship research supports his view as well. 80% of married couples have sexual affairs in most cases, because they don't know how to:
1) Distinguish between short term payoffs (sex, emotional excitement etc) vs long term harmful consequences and lost benefits - harming their partner, family etc. Long term healthy marriage is protective spiritually, psychologically and physically (you live longer).
2) Identify high risk situations for emotional, leading to sexual affairs (usually at work, increasignly online)...and bring these immediately to the partner for joint problem solving...
3) Effectively setup boundaries and transparencies to protect their marriage and each other emotionally, as bonding events.
4) Effectively communicate and reciprocally meet core-relationship needs, whose chronic frustration increase the likelihood of transgressions, coercive communication and emotional shutting down/avoidance patterns in the marriage.
Yes, affair-proofing a marriage is very much like behavioral relapse prevention around unhealthy habits like over eating or drug abuse.