This memory was referencing an earlier joke, where Riley's mother was angry at her husband when he failed to pay attention to Riley's problems:
Mother's emotions: He's making that stupid face again. I could strangle him right now. Signal him again.
Father: So, Riley, how was school?
Mother's emotions: You got to be kidding me! Seriously? For this we gave up that Brazilian helicopter pilot?
So he's apparently just an old acquaintance of Riley's mother, that she gave up for Riley's father and that she still tends to escape to in her fantasy whenever she gets upset at her husband.
Now why does the teacher remember him too? Well, first of all, this occurs in a sequence of jokes playing with the whole "look inside the head" notion of the film and driving it ad absurdum. So this is first and foremost just a recall to a previous joke in order to make you laugh.
But in fact, the fact that she sees the exact same guy has another layer of joke on top of it. It probably is the exact same Brazilian pilot and the teacher knew him too. This implies that this guy wasn't as much of a romantic person as Riley's mother (and teacher) might think and probably said the exact same line to quite a bunch of different women.