Oh @Flower012 what a horrible situation.
You’ve had some great advice from some posters above, especially @ItPearl.
All I would add - as someone who was cheated on and had several vindictive OW try to cause as much pain as possible to me - is that while you didn’t behave brilliantly, he is the one responsible for his actions regarding his wife.
It’s unlikely you were the first or the last. People like him are very skilled at finding and stringing on unhappy women until they no longer serve a use.
You didn’t lose a prize in your AP and his wife certainly hasn’t won one.
I would disregard the posters on here who would love you to spend the rest of your life torturing yourself with guilt and recrimination.
Life is not black and white. None of us are perfect.
You need to look at why you are drawn to men/relationships where your emotional needs will never be met.
Why you are choosing to stay in a dead marriage with a man who doesn’t care for you.
Why you idolised a man who didn’t care for you. Because, I’m sorry to say, whatever he said or did, he did not care for you. He told you whatever he needed you to believe so you would stay.
You deserve to be happy and loved.
You won’t believe that or find the right relationship for you until you do some serious work on your self worth. And forgiving yourself will be part of that.
Good luck 