Garlic is full of sulphur-containing chemicals, that give it its familiar taste and odour. One of them, called allicin, is probably responsible for making your hands smell. Stainless steel is an alloy, which is predominantly made of iron but also contains chromium. The chromium forms an oxide layer on the surface of the alloy, protecting the iron from rusting. It could be that the oxide layer reacts with the allicin from the garlic, making it cling to the surface of the stainless steel instead of your hands.
Subscribe to BBC Focus magazine for fascinating new Q&As every month and follow @sciencefocusQA on Twitter for your daily dose of fun science facts.