Many were centrists with strong national security credentials and were elected in the anti-Trump midterm wave four years ago. But most survived this year, even in tough G.O.P.-leaning districts.