When you see a happy person, some of the neurons in your brain react, as if you are experiencing happiness yourself. These are called mirror neurons, because they mirror the emotions of people around you. This is why yawning is contagious – as are feelings such as anger, joy and motivation. Who you spend your time with, influences who you become.
Mirror neuron (Wikipedia)