You have asked a question that science, as yet, cannot answer. By chance, I just read a book about it: The Emperor of Scent by Chandler Burr. On the surface, the book is about perfume, but it’s actually about the fact that no one can conclusively claim to know how smell works.
It was thought for a long time that we could smell based on the shape of molecules. It was thought that we evolved with receptors in our noses that were ready to accept smelly molecules based on their shapes. A shape was predestined to fit a particular receptor.
There were problems with this theory, because wildly different molecules can have the exact same smell. There were attempts to explain this away, but the problems persisted. Most scientists accepted the problems and moved on.
Luca Turin, a microbiologist who happens to be very interested in perfume, began to have other ideas. He thought that we might smell based on the vibrations that molecules give off. He did some experiments and had some success.
The book has a lot of science in it that I skimmed, because it’s just too technical. In the end, there is no evidence yet that concludes the debate.