The answer to this question would be: limbic system
Limbic system is part of the brain that responsible for emotion. One of this part is the olfactory bulb where the smells are processed. That is why a smell of something might make someone remember some memories that were related to the emotion.
In some organism, smells is important for survivability. Smelling a predator might cause the organism to feel fear and run away from them before they got close.