I can't help but wonder where they pick up that habit. I do know that kids will often learn some social ritual or merely some silly sound they can make and repeatedly test it- not something I recall ever doing myself, but it's a possibility.
I assume that they assume that the automatic and mandatory response is to wave and say "Hi" back, having some inkling of the concept of a greeting. Of course, anyone who gets beyond this phase knows that isn't so.
This is why I make it a priority to never encourage this behavior by responding, so I try to ignore them. I always took the "don't talk to strangers" bit seriously, and I still do.
But what do they expect to achieve from doing this? I know most don't rationalize or think about their reasons and/or motivations to do certain things, but those reasons and motivations still exist in everyone. The kid perhaps doesn't know what he/she really wants, but does it anyway for whatever subconscious reason.
Perhaps I'm overanalyzing this, but it sort of creeps me out.