Hey - I've created a login to post on this thread - because the OP may as well have been me a few years ago.
3 kids - caught my wife sexting on multiple occasions.
I'm afraid in my case the story did not end well - we are now separated for over 18 months (relationship effectively ended over a year prior to to the actual physical separation - but sorting out all the financial/ practical/ telling the kids stuff took a while)
My approach to dealing with things was very much like yours - I looked to myself and things I had been doing that were "wrong", but the reality was that she had effectively stepped away from the marriage. She enjoyed the excitement and attention - and her behaviour escalated to her going out with single friends, meeting men, staying out all night etc etc
I gave up challenging her when I found evidence that she was cheating (emotionally or otherwise) - there are only so many times you can go through the process of going "ah ha I caught you", her denying it/ realising she's been caught/ saying "sorry it won't happen again", then going on to do it again anyway.
She was never honest with me about how she felt or the truth of what was going on - and she wasn't honest with herself about why she was doing these destructive things. Looking back there was nothing I could do to change the way things worked out, the ball was in her court to change her behaviour/ commit to marriage counselling etc - but she couldn't do it.
The best thing I could have done was ended things myself sooner - instead I sat back and watched my marriage die over the course of a couple of years. It wasn't fun ..
My advice to you is to say to her "no more" - if it happens again the marriage is over. Do the counselling, don't hide your true feelings, leave it to her to do what is needed to make "you" feel secure and wanted. If she can't or wont do this then your marriage is over - walk away with your self respect at least partially held high.
It's not all doom and gloom - I have lived for 18 months in my own flat, the kids live with me 3 nights a week and they are happy and settled, I'm getting on OK with the ex (we will never be best friends, but we keep things civil), I've been dating and have met someone fantastic. Its good to be in a non-toxic relationship - you forget what it feels like.
It's admirable that you still love your wife and want to do the right things by your kids - but don't loose sight of yourself or your long term future and happiness.