The mechanism of displacement
This mechanism causes the redirection of an impulse, i.e., desire from one object or person to another and the redirection of anger from one person to another (usually onto a powerless substitute target) or an object.
For example, we desire sexual pleasure and since we do not have the opportunity to enjoy it at that moment the desire for pleasure is directed to another object that we can easily obtain, for example, eating a chocolate.

Anger can also be directed towards ourselves, especially when when we suffer from guilt and low self-esteem.