When you hear about someone who has cheated on a spouse, they normally will say, "I never meant for this to happen." While this is probably true to some point, they did allow the chance for it to happen. The only way it could happen is if the situation was right.
First you must keep in mind that men and women are very different. Men are a bit naive when it comes to what a woman is truly capable of. Women are planners, and if they are interested in a man they will find a way to weasel themselves into his life, married or not. They will find out where he eats, where he hangs out with his friends, and where he works out. She will keep finding reasons to be where you are when you are there. Most men think that this is a coincidence when in fact she is carefully stacking her cards to make a move. So the very first thing is don't be naive.
The most important thing to remember if you truly want to stay faithful, is to avoid situations and temptations. Don't even go there. If you feel an attraction to someone, that is completely normal, but stay away. There is no good that will come from that. Never be alone with that person, and if you have to be with her, do it in a group, preferably with your wife in tow. Then you can be sure nothing can happen. If someone lets on that they are interested in you- diffuse the situation immediately, be firm.
If you do not allow the situations to present themselves, then they will not. be sure to steer totally clear of even flirting, as this can give a woman the wrong idea.
Focus your energy on your marriage and if you are having marriage problems then seek out the help from a marriage counseling expert. An affair will only compound your problems, it wont make anything better.