It sounds a lot like simple justification.
You heard stories from your friends... yeah. They were complaining that their men wanted them, LoL.
If your needs aren't being met then you need to communicate that clearly to your partner. It is incredibly difficult. This is part of marriage. Conflict is a part of life.
It sounds like this went on for years and was never resolved.
That. Is. On. YOU!
I'm sorry, but having an affair is wrong. I said it.
There's absolutely no reason why you couldn't have come to your current understanding without having an affair. None.
It was just easier for you to take this path.