I agree with talking to a doctor- some of these thought patterns can be typical of people suffering from depression or anxiety, and if that is a factor, treatment will help.
I've dealt with this at various times in my life, and I finally figured out that when other aspects of my life are going poorly, I tend to beat myself up rather than looking around to see if there's something in my life that's beating ME up. Look very honestly at your family relationships, your friends, your work environment- are the people around you building you up and supporting you, or are they tearing you down? Are the tasks in front of you- at work, or at home, or in your social life- concrete and attainable, or do the people around you take the attitude that you could always do more- and therefore you never feel you've done enough?
I'll say this- a message I received frequently growing up was that if I had a problem, I should look to myself first to see if I had played a part in it by being inconsiderate, not working hard enough, not thinking of it from the other person's perspective, etc. Add to this messages like, "Nobody's ever 100% right in an argument, there's always fault on both sides," and "Don't ask for an apology unless you're ready to offer one yourself for your part." I REALLY internalized that, and if anything goes wrong I immediately look for ways to blame myself. I'm more comfortable telling myself I must be unmotivated or lazy or stupid than I am thinking that I've done all I can and my work demands are unreasonable- even if other co-workers have said the work demands are insane. I'm more comfortable telling myself I must have done something offensive than that a friend is taking out her anger or frustration on me- even if she tends to do that to others, and I can't think of a single thing I could have rephrased.
I didn't mean to write a novel- it's just that I've felt before exactly the way that you describe, and realizing all of that was what really helped me. The last time I felt like that, I ended up leaving a very toxic work environment for a much better one, and I feel so, so much better. I hope something in what I wrote helps you- if not, I hope you find an answer that helps you and feel better soon!