Self-serving bias
From BurnZero
A self-serving bias occurs when we interpret the world in a way that is beneficial to our sense of self. This is not necessarily a bad thing, but it often is.
For example, the tendency to attribute successes to our diligence and hard work and failures to external causes is one manifestation of this bias. Another manifestation is the tendency to justify our own bad behavior based on external pressures. (It’s not my fault because…)