Gifts from stranger

Starrlight
Today I was at the check out line with groceries and my daughter was playing with a pack of Hotwheels cars. She didn't ask me for them so when it was time to leave she put them back without a fuss. As I was loading my groceries in the car and older gentleman said "excuse me Mrs. I noticed your daughter playing with these,I bought them for her" My daughter and I both thanked him then left. Although it was really sweet and generous I had the talk with my daughter about not ever accepting gifts from strangers. What are your thoughts on it? Honestly it was nice but I'am also a little weirded it by it.