We generally assume that there is a "self" existing within us that defines who we are. It may be more correct, however, to think of the self as modular — much like a set of apps on a smartphone.
Robert Kurzban, writing for Psychology Today, posits that the idea of a "me" who is really in charge of everything we do is just an illusion. Instead, we have multitudes of different "apps" in our brains that account for our behaviour, which is often contradictory.
[T] he idea that there are "multitudes" in your mind helps to explain various kinds of inconsistencies. If there's a lot of applications in your head, then they can be doing different things at the same time; oddly, this means that different applications can have different and contradictory beliefs in them. Further, suppose that, just like a smart phone, different applications are in the foreground or background at different times. If behaviour depends on which applications are currently active, then individuals can seem to be very different people at different times, depending on all the details of which modules are currently active.
This accounts for why you often have contradicting thoughts in your head, such as trying to resist a cookie on a diet or not being attracted to a person who you know is a "good catch". While there isn't necessarily a solution to the problem — your brain isn't so much like a smartphone that you can just quit an app you don't want running — awareness of your contradictions can help you stay ahead of them and not end up helpless the moment they present themselves.
For more information, check out Robert Kuzban's book Why Everyone (Else) is a Hypocrite.
Is Your Brain Like an iPhone? | Psychology Today