Katie Ledecky became the second swimmer to win an event at four straight Summer Games, holding off Ariarne Titmus to win the 800-meter freestyle.