How to deal with past mistakes

I often feel like my brain is persecuting me, especially when I let it wander. For example, when I’m washing the dishes or gardening or lying in bed in the middle of the night, old thoughts will float up–and often, they’re about past mistakes. I’ll remember the time I humiliatingly blew that job interview, or think about my old boss who ended up hating me, or that time I unthinkingly said something cruel. And it isn’t just that I’ll remember–I’ll suddenly be emotionally back in that place, feeling the shame or frustration or humiliation I felt then. I don’t know why this happens, and I’m not sure what to do about it. Is it best to do a model on every past situation as it arises? Or do you have any other suggestions to help stop what feels like self-persecution from my own brain?