For Thomas Crooks, the suburban Pittsburgh nursing home where he served meals and washed dishes for $16 an hour was another solitary corner of a nearly invisible life. He was polite but distant, a former co-worker said, ate lunch alone in the break room and rarely spoke with anyone.

But as western Pennsylvania geared up last week for the boisterous spectacle of hosting a rally for former President Donald J. Trump, Mr. Crooks approached his bosses with a request, law enforcement officials said: He wanted to take Saturday off.

He told them he had something important to do.

It was one of the few hints to emerge so far that the 20-year-old engineering sciences graduate was planning to become a political assassin. A week after Mr. Crooks opened fire at the rally and was killed by the Secret Service, his ideology and motives remain a vexing question for investigators and the people who crossed paths with him.

In dozens of interviews, former classmates, teachers and neighbors said they still could not square their memories of Mr. Crooks — an awkward, intelligent teenager who liked to tinker with computers and spent his weekends playing video games — with the image of the stringy-haired gunman at the rally, armed with his father’s AR-15-style rifle as he clambered onto a rooftop and took aim at the former president. Mr. Trump suffered an injury to his ear, and three spectators were wounded, one of them fatally.

“That’s where I’m struggling — I’ve looked at horrific pictures of an individual that I stood six inches away from, shaking his hand, calling on him in class,” said Xavier Harmon, who saw Mr. Crooks almost daily in the computer technology class he taught at a technical school.