Michelle Yemba, who is 6 years old, often tells strangers about the time two years ago that she met the president of the United States.

The conversation started during a surprise visit by President Obama to her Head Start program in Lawrence, Kan. Mr. Obama (pictured at the program with Akira Cooper) told Michelle that he knew someone else with the same name — one of his favorite people, he said, coyly referring to his wife.

“He has just a natural flow with the kids,” said Clara Cox, director of the Head Start program, recounting the visit.

One of Mr. Obama’s lasting legacies may be the symbolic impact on the generation for whom “president of the United States” has always referred to a black man. Tapping into that at events throughout his two terms, he often seemed to assume the role of national dad — embracing the children of strangers as if they were his own.