Rarely do I get a question with such a straightforward answer. Though the male subconscious is a mystery as fathomless as the Loch Ness Monster (in that it probably doesn't exist), there are only a handful of reasons a guy would ever exhibit this particular behavior pattern. Here's every thought that could have been going through his mind, from most likely to least likely yet most entertaining.
"Damn, boo be smokin'. Them titties like 'what what!' Oh, crap, she's looking over here--AVERT GAZE! You make me sick. How dare you objectify a woman like...hey, she didn't notice. Flash them pearlies, g. Bitches be wantin' 'dis!"
"There she is; the love of my life. I've wanted to ask her out as long as I can remember. If only she'd notice me. Oh crap, she noticed me--AVERT GAZE! You're pathetic, you miserable coward. Now grin like a tool and back slowly out of the room."
"Whoa, check out that weird looking guy. Oh, snap, I think that's a woman. Her head looks like a wombat. Oh God, it's turning this way--AVERT GAZE! You jerk. Imagine how that makes elephant woman feel. There you go, give her a smile. Okay, vomit coming up; sprint for the toilet."
"I am soooooo drunk right now."
"Observing human female. Gender seems to be identified by brightly colored garb and overdeveloped mammary glands, colloquially known as "titties like 'what what!'" Subject alerted to our presence--ALTER OCULAR TRAJECTORY! Initiate apologetic facial expression, slowly withdraw from quarters."
There are various tests by which you can determine which thought pattern your mystery man was running through his brain, but most are painful and prohibitively expensive. My best advice is that you assume he's a hostile alien cyborg and alert the proper authorities.