There are multiple theories on emotions. Theories on how many emotions are there, how emotions are formed and why emotional intelligence is more important , etc.
In my understanding, basic emotions comes with base brain. Feelings of happiness are linked to prefrontal cortex. Anger, fear, sadness, etc kind of negative emotions are linked to amygdala. I think, based on various factors like genetics and others your base brain and emotions gets formed. This is like you are born with out-of-box feature (in software product terminology). Then the customization happens to your brain and emotions. How does this happen? Customization happens based on beliefs, experiences and how you interpret those experiences.
I am sure your heard the phrases like “This is how I am “wired” or born with”. You see some people by nature are very happy and optimistic. While others are pessimistic and sad. These people brain is wired with these emotions. Until very recent time, scientists used to think that you can’t change your brain wiring. But fortunately, now scientists have discovered “Neuroplasticity”. This means your brain can change on its own based on what you feed (experiences, interpretations, ect) in. So the good news is you can be optimistic – called “learned optimism” with practice.
Sequence is some what like this (not necessarily real sequential) Brain <-> Beliefs <-> Emotions -> Actions -> Out comes. Finally what really drives you is emotion. This is why it is very important to have a handle on own emotions. But this is not easy and it is complex. This why there are many theories and books are written on emotion intelligence. All leadership finally end with EQ (Emotional Quotient).
All the decision making happens based on individuals own emotional strength/weakness. Every relationship is based on the emotional mix of two different people.
So how do we get to know our emotions well?. While there are many tools on this, I think the single most tool that is far more effective is Mindfulness.
Find your own tool/approach to master your emotions. Most problems can be solved with this single mastery.