Individual preferences are formed under the influence of a whole complex of factors that interact with each other and continue to influence our addictions throughout life. It is impossible to describe all the intricacies in one short summary, but I will try to cite the main patterns in my answer.
Our taste and smell preferences are determined by genetic factors and previous experience. A dislike for the smell of cilantro, for example, is due to variations in the sequences of three genes associated with the perception of bitter taste, pungent odors and the transmission of gustatory stimuli. Variations in the sequence of genes for taste buds are also known, which explain differences in the perception of the intensity of bitter and sweet tastes. Hate the smell of man's sweat and when your partner fries fatty pork, and he / she does not feel this stench? Most likely you have different variants of the OR7D4 olfactory receptor, which is responsible for the ability to smell androstenone. In addition to genetic variations in the sequences of genes for olfactory and taste receptors, sensitivity, and therefore the perception of smells and tastes, depends on the number of specific olfactory and taste receptors sitting on the tongue and in the olfactory expulsion of the nasal cavity. The number of receptors can change with age, and just from day to day under the influence of external factors.
Rejection of bitter, love for sweet and salty are inherent in us from birth. These taste preferences are an ancient evolutionary mechanism that allows you to avoid toxins, which are mostly bitter, choose energetically beneficial foods high in simple carbohydrates, and take care of water-salt metabolism. More complex taste and smell preferences are based on our sensory experience and associative learning. For example, babies prefer mom-related scents. With age, more and more smells appear in our horizons that are associated with pleasant and unpleasant situations, people, they acquire an appropriate color. When it comes to food, the simplest example of associative learning would be food poisoning. If you are properly poisoned, then for a long time you will avoid foods with which you associate this nauseous condition. Conversely, foods that are satiety and fun without consequences will become more and more pleasing to you. A very significant part of our taste preferences is formed in childhood (I wrote about this here: https://thequestion.ru/questions/3587/kak-formiruyutsya-gastronomicheskie-pristrastiya-u-lyudei).
Most scents in nature are, in principle, neutral, but, of course, they carry certain information. There are smells that we learn to avoid socially and culturally, and they are associated with sanitation and hygiene. I note that in nature, animals do not avoid, for example, the smell of feces, small children too (yes, yes, we were happy to play with our poop when our parents were not quick enough!). But parents consistently form "correct" patterns of perception of such smells. For the most part, our attitude to smells is associated with imprinting, that is, imprinting our state at the moment of the first meeting with it, or conditioned reflexes. We pay little attention to smells, although they play a rather large role in our life. Therefore, we do not notice, do not fix the situations of the formation of our attitude towards them. For example, a woman who is abused when a man smelled like a hugo boss may later in life experience an unconscious fear when she smells this smell. Or we had romantic dates in an Italian restaurant, and in the future we will be attracted by her smells, although we did not pay much attention to them before.
With a slightly different taste. In addition to the same mechanisms, physiology is added here. We are slightly differently arranged, including genetically, for example, most people can drink beer with pleasure, but 10% have a mutation due to which the taste of beer becomes unbearably bitter. Another example - often women love chocolate because it contains substances for the synthesis of serotonin.
Well, something like that.
It seems to me that this is a protective function of the body so that a person does not harm himself by eating rotten food or, excuse me, feces. Or if it smells of some kind of gas, then the person will avoid this smell and thereby save his body.
The division into pleasant / unpleasant is somewhat arbitrary. It happens that a person may like something that causes negative emotions in others. Someone likes how gasoline smells, some don't, for example. If you look at this objectively from the side of the smell of freshly brewed coffee and a bun, for example, and the smell from a garbage can, then in the latter case, the objects lying there begin to decompose and rot and at the same time contain toxins and poisons dangerous for the body. Upon contact with oxygen, a characteristic odor appears (I will not delve into chemical reactions). Given that the product is already dangerous, there is no better way for the body to understand that it is dangerous without harm to itself and direct contact, except by smelling it. And coffee and a bun are quite edible and do not pose a danger for the time being, therefore they do not cause such negative reactions.