A handful of Democrats scored improbable victories in races against Republican incumbents who were favored to win.