"To keep you from the evil woman, from the smooth tongue of the adulteress"
Solomon is warning his young student – who wants to learn wisdom – to listen to the commandments of the Scriptures for they will form a protective wall between you and the serious sin of adultery.
Just recently I was interviewing a man who got involved in adultery and he said what they all say. He allowed this person who was not his spouse to meet relational needs that only his spouse should have been meeting and eventually the relationship grew until it became sexual. This is how it always happens in long-term affairs. There are one-night stands that are just stupid decisions to give into lust; but they are usually encouraged by alcohol, drugs, loneliness, depression, wrong friends, pornography, etc.
Once you have begun to connect with an adulterer or adulteress, relationally it is too late. The time to stop is way before you ever meet this person. Do not allow yourself to have your relational needs met by someone who is not your spouse. If you are single, then do not allow your relational needs to be met by someone who could not or will not be your spouse someday.
What are your relational needs?
Well if you are a man, they are usually: Respect, Adaptation, Domestic Leadership, Intimacy, Companionship, Attractive Soul and Body, and Listening.
If you are a woman, they are usually: Honor, Understanding, Security, Building Unity, Agreement, Nurture, Defender.
When someone meets these needs, we are drawn toward them. Do not underestimate the power of these relational needs. We are drawn towards anyone who will meet these needs, but we get to choose who we let meet these needs. Unfortunately many people in marriage have decided to no longer meet the needs of their partner, and this puts greater tension on the individual to find someone who will meet these needs. It is always a mistake to look to someone other than your spouse to meet these needs even if for a period of time your spouse is not meeting your needs.