Dogs don't generalize well.
This is why you have to teach them to do something, then practice with them doing that something in a million different situations to get them to be really and truly reliable. You saying 'come' to your dog when you're in the house or on a walk or whatever looks...