The academic term is self-handicapping, described by Edward Jones and Steven Berglas in 1978. The original experiment: participants who had been praised for a success actually obtained by chance chose, before the next test, a substance they had been told would lower their performance. They preferred a real obstacle to the risk of learning they were not good.
That is the logic. Self-sabotage creates, in advance, an alternative explanation for a possible failure. If I slept four hours, a weak presentation says nothing about me. Procrastination, drinking before an exam, picking a fight before an important holiday — all move the cause outside identity.
The relational form is the most painful: the closer someone gets, the greater the fear of loss, and pre-emptive sabotage converts a possible, uncontrollable loss into a certain, controlled one.
What helps is not “more discipline” but identifying what the behaviour is protecting. A pattern that serves a function does not disappear because it is criticised.