The built-in predicate repeat behaves as if defined by:

repeat :- repeat.

Thus repeat succeeds when first called, thanks to the first clause. If the Prolog interpreter subsequently backtracks, the second clause (repeat :- repeat.) is tried. This initiates a new call to repeat, which succeeds via the first clause, and so on.

For a practical example of a use of repeat, see here.