Family members often visited their spouses at the San Bernardino, California, school, and school staff recognized Anderson as Smith's new husband.
He signed in, and did not appear agitated on Monday. There was no indication of the violence that would soon come.
From the office, Anderson walked into classroom B-1 and, without saying a word, opened fire at Smith from 10 to 15 feet away, according to a sequence of events presented by San Bernardino Police Chief Jarrod Burguan.
In all, Anderson fired 10 shots from a Smith and Wesson .357 revolver, stopping to reload, police said.
Smith, 53, was killed in the shooting. Student Jonathan Martinez, 8, who was sitting behind Smith, was shot and killed as well.
Another student, Nolan Brandy, 9, was also behind Smith when he was hit in the upper body, police said. He is expected to survive.
Anderson then shot himself to death, police said.
Officials provided those details at a news conference on Tuesday, a day after the episode sparked fear throughout the school community in the California city all-too-familiar with high-profile violence.
San Bernardino was also the site of a terror attack in December 2015 in which a couple shot and killed 14 people
at an office holiday party.
Community members gathered for a vigil Tuesday evening, to mourn the two victims and left flowers, teddy bears and balloons at the elementary school.
When school staff let Anderson in, they didn't know his relationship with Smith was on the rocks, police said.
The two had dated for four years and got married in January. On Facebook, Anderson posted happy images of the couple enjoying date nights and smiling in selfies.
But those close to Smith told police she said Anderson's behavior had become odd and he had threatened her, Burguan said.
Smith moved out of their home in March and went to live with other family, he said. Yet those at school knew nothing of this discord.
"She effectively kept her private life private," Burguan said.
"There was no indication to anyone on staff that there was a potential threat," San Bernardino City Unified School Superintendent Dale Marsden said Tuesday.
Burguan said police searched Anderson's residence and did not find a suicide note. They did, however, find a note believed to be written by Anderson that spoke of feeling disrespected and needing to find closure. The note would not have been alarming if not for this violent event, he said.
Family of victim asks for privacy
The family of Jonathan Martinez, the 8-year-old student killed in the shooting, did not wish to speak publicly, Marsden said.
They did, however, wish to bring attention and consciousness to an issue facing Jonathan called Williams syndrome.
Williams syndrome is a genetic condition that is characterized by cardiovascular issues and development delays, and it affects an estimated 20,000 to 30,000 people in the United States, according to the Williams Syndrome Association.
Like others with the condition, Jonathan was social and had an affinity for music, and he brought joy and perspective to his family, Marsden said.
The Mexican government issued a statement regarding the boy's death, saying it "profoundly laments the death of a minor with Mexican nationality and the death of his teacher." The consulate in the city was in contact with his parents and called for a full investigation, according to the statement.
Survivor's family is 'grateful'
On Wednesday, Nolan's parents, Leon and Rachel Brandy, thanked the community for their prayers and support.
Their son was recovering, the couple said in a statement.
"We are grateful," the family said. "Please continue to pray for him and also for Jonathan Martinez's and Karen Smith's families."