As someone who has wasted way too long beating herself up over past mistakes, I can say only that no one lives a perfect life; no one makes the optimal decision every time. The question is what kind of mistakes are you beating yourself up over? Sometimes you make a mistake because of faulty logic, poor analysis, emotional reactions, laziness/sloppiness, etc. E.g., I thought a bigger house would make me happy, but now I am spending too much time taking care of it and resenting the higher mortgage and utility bills. These are useful mistakes: they are how most people learn what works and what doesn't so they can make better decisions in the future. In these cases, regret is a useful nudge -- it is a mental reminder of how you got it wrong in the past, so you don't repeat the same mistake in the future. But there is still no reason to beat yourself up. As Maya Angelou said, you did what you knew how to do; when you knew better, you did better.
But sometimes you make a reasonable choice given the information available to you, and things turned out poorly because your information was imperfect. You see this with, for example, investing: if only I'd known that the market was going to crash, I should have gone all cash and jumped back in when it turned around -- or, more frequently, if only I'd known that the market was going to turn around, I'd have jumped back in! When the reality is that no one can possibly tell exactly when the market will drop or rise; there are thousands of extremely intelligent people, with Ph.Ds and all the sophisticated computer power they could possibly use, who get paid a shit-ton of money to call the market -- and even they get it wrong. So what chance does a normal average human have of doing better?
These kinds of regrets are completely useless; there is nothing to be learned from them (other than that, yes, you are human, and humans are not omniscient). At best, they are a waste of time; at worst, they add stress and anxiety by making you feel responsible for events that are completely out of your control.
Tl;dr: if your mistake is something you can learn from, take it as a gift that you learned that lesson when you did instead of years or decades later, and do better in the future. If your mistake is due to circumstances beyond your control, let it go.