Sen. Ed Markey bested Rep. Joe Kennedy III after turning around a race that initially looked to swing in the young congressman’s favor.