In a nutshell
KMP (Knuth-Morris-Pratt) never re-reads text it has already matched. Before searching, it builds a small prefix table from the pattern — also called the failure function — recording, for each position, the longest stretch of the pattern's own start that also appears ending right there. When a mismatch happens partway through, that table says exactly how far the pattern can jump forward without losing the part already matched, so the text is scanned just once, in linear time.