KAZAN, Russia—There’s no stopping Katie Ledecky. The 18-year-old American virtually raced herself at the world swimming championships, and she was unbeatable.

Ledecky ended her meet in spectacular style Saturday night, lowering her own world record by 3.61 seconds in the 800-meter freestyle for her fifth gold medal.

She swam the 16-lap race...