There is a famous Latin phrase - "errare humanum est," which means "to err is human." It doesn't just apply to particularly bad or foolish people, but to people in general. People make mistakes, and it's inevitable. We associate with people we shouldn't have, get into arguments with those we shouldn't have, invest in failed projects, involve ourselves in movements we should have avoided, harm our reputation, health, and relationships with others. Unfortunately, it's part of our nature. I have made mistakes before, and I will make mistakes again.
People tend to stick to decisions they've made, even when it's obvious they were wrong. "I've spent so much, suffered so much, and sacrificed so much - was it all for nothing?" Common sense tells us that yes, it was. You made a mistake, got deceived, bet on the wrong horse. It happens. But pride shouts, "No! I did everything right!" and common sense gives way. There's a joke about a fashionista who bought a bow and then had to buy a bag, shoes, dress, car, and country house that would match it in color. Often people make a relatively small and fixable mistake and then decorate it with increasingly expensive mistakes that should justify it.
For example, people become members of cults. The self-proclaimed guru or prophet becomes increasingly creepy, but too much has been invested, too many hopes and efforts, and it's too difficult to back out.
Therefore, a very important life skill is what is called "minimizing damage" in business circles. To get out of mistakes with the least losses. And again, it's essential to acknowledge that mistakes and losses are inevitable. But you can avoid digging yourself deeper - if you fall into a hole, stop digging. Step away from the argument, keep silent. Stop loudly swearing allegiance to a cause that turned out to be false. It's not necessary to publicly beat yourself up - just quietly retreat to the side.
Accept the fact that people make mistakes, and I have made a mistake. Think about how to fix it. Restore relationships - or, on the contrary, distance yourself from unkind and dangerous people. Learn lessons and move on.