That's a shared chore. Do you not see the obvious differences in the situation? If they said "you're welcome" about an obligation like paying taxes and also made it very personal, then it would be close in feeling to your scenario. But it's not. If you offer a genuine gift, in a situation where there is no expectation of payback or debt, you can say you're welcome.

It’s impolite and weird to say “you’re welcome” when offering a gift for which the recipient did not first express gratitude. It follows “thank you;” it does not precede it.

Try this instead: give a stranger a piece of pre-chewed gum and say “you’re welcome!” Hell, even if it’s not pre-chewed, it’s just presumptuous and rude. You have no idea if they value it or not. They might not even like it.

Even if my barista handed me the coffee I ordered and said “you’re welcome” before I thanked them first, I’d think they’re a little off kilter.