The sixth-seeded Williams served for the match at 40-0, but Ahn saved three match points. An ace gave her a fourth opportunity to win, but she hit a shot into the net.
Williams then saved a break point before finally beating her American opponent with an ace.
Ahn held leads of 3-1 and 4-2 in the first set.
The 39-year-old Williams is a three-time French Open champion and is looking to equal Margaret Court’s record of 24 major titles. She will next face Bulgarian wild-card entry Tsvetana Pironkova.
Vondrousova was the third-lowest ranked player to reach the final last year when she did so at No. 38. Swiatek reached the fourth round at Roland Garros last year. The 19-year-old Polish player will next face Hsieh Su-wei of Taiwan.