What century were you born in. Are you even married? How many years?There is the pop-psychology way of looking at this, and then there is the truth.
Men are not monogamous by nature --we become fascinated by women and drawn to them, and it isn't just one woman. No matter what every guy on this forums says about being a white knight who only has eyes for his wonderful wife, this is the truth.
Men sacrifice romance and autonomy in order to build a family with a good woman. We take a risk and invest in this family, and forgo romance with other women.
Why is this important? Because:
1. You are resentful you had to give up this autonomy and access to other women. Most guys feel this at one point or another, but you let it fester in your mind to the point that you started reaching out in cyberspace to other women. You tried to recreate the thrill of a new romance.
2. This doesn't mean you don't love your wife. Ponder on that one ...
The blow to your mental health is an excuse, or a midlife crisis. A lot of people have had blows to their mental health, but they didn't go have affairs
Dude: be 100% honest with your wife on this: no excuses, no sugar-coating, no complaining about depression and anxiety. Come clean and you will reach an understanding.
we are all human beings, and we all have faults and character flaws
STOP complaining about your mental health, and stop being weak around your wife. No tears and pity --it isn't masculine
No "therapy" or counseling. It isn't productive for men in regards to stuff like this.
Your wife will get over this and respect you again if you come to terms with why it happened and are honest with her.