The two shootings were separated by seven days and more than 1,500 miles, but the details seemed eerily familiar: When a gunman charged into a classroom, a student went barreling toward him, preventing more bloodshed while sacrificing his life.

At the University of North Carolina at Charlotte, it was Riley Howell, 21. At the STEM School in Highlands Ranch, Colo., it was Kendrick Castillo, 18. The two young men were hailed as heroes for assuming the unimaginable role of emergency responder to a school shooting.

Their actions, credited by the authorities with saving the lives of classmates, suggest that some members of America’s mass-shooting generation have learned to act — by instinct or intention — as professionals would in the face of deadly tragedy.

“I think everybody has this idea, ‘What if somebody comes in with a gun? What do I do?’” said Brendan Bialy, 18, who said he helped disarm the Colorado shooting suspect, a fellow student, after Mr. Castillo charged him. “I didn’t think consciously, ‘I’d do this and then this.’ It just happened.”