I understand your concern.
In my view every relationship has a specific duration. Some relationships last for a life-time while other last only for a few months. This cannot really be predicted, because the duration of the relationship is based on how the two parties manage it.
What you are describing is where people have ended their relationship at some level - be it physically, emotionally or spiritually, but they do not acknowledge that to themselves or to their partners. Instead, they choose to be dishonest and start a new relationship while they still have ties with their current partner.
I fully believe that when you find your lovely wife, you will be faithful to her, because that is your nature. Because you have your eyes wide open, you will probably find a lady who shares your beliefs. Your values do not only apply to marriage - marriage is a legal and/or religious contract. Your values apply to having a relationship with even a friend or family member.
The question is not really how you can prevent unfaithfulness in your marriage - because there is no secret recipe.
The question is whether you accept that for some people it is OK to be unfaithful, but that you made a conscious choice to deal with any issues in your relationship and make a success of it.
Obviously people who have extra-marital affairs do not choose to confront their marital problems, but rather add to them, and they then have to deal with even more issues eventually. You have already realized that by observing these people and their affairs.
Take your time and follow your heart in choosing your marriage partner. Once you have done that, you will have the emotional maturity to deal with any issues that you are confronted with.
To read more about dealing with relationship issues: