Why do we repeat the same negative patterns?

Some of us seem to repeat the same patterns over and over again. Choosing the wrong partner is a common situation that illustrates well this mechanism.Usually, people in a dysfunctional relationship are aware that it is not right for them.
However, they can’t stop it or when they manage to do so, they tend to recreate the same conditions in a new relationship by, for example, choosing a partner with similar personality traits to the last one.
These types of behaviours can create intense emotional pain, frustration and a sense of defeat as we don’t seem to be able to change them. This often makes us feel blocked and trapped, almost like if we were controlled by some sort of pre-defined script that we have to follow.
These behaviours are automatic responses that come from a part of our mind that is not ruled by rational processes. Unprocessed stressful or traumatic experiences are one of the root causes of the tendency to fall back into recurrent patterns. These past events get reactivated by current experiences and make us feel anxious, fearful, depressed, angry.