What to do if the betrayed is now the unfaithful?

Hello,
Can you please help me understand what to do if the betrayed is now the unfaithful spouse who wants me (and our children) whenever he feels like it, but then drops me and goes chasing others or his own thing whenever he feels like it?

Out of a desire to offer restitution I have tolerated a lot for a long time (5 years since d-day) and can see it’s his hurt that causes him to swing back and forth, but I’m really afraid of the example I’m setting for our children, and that I’m not really genuinely loving him or myself by not having boundaries. It also causes me to get really angry sometimes and snap and lose it and be frightfully angry at him, which doesn’t help at all, only making things worse and fuelling his self-righteous indignation.

Whenever I have tried to have boundaries it has been like a red flag to a bull - any tips would be very much appreciated!