I don't see any loop here except a recursive call passing the same y to ys
The recursive portion is passing the tail of the list to the elem' function, not the same list. Therefore, once it has gotten to the end of the list, the only tail remaining is the empty list, [], which should terminate in another function pattern like this:
elem' _ [] = False
Edit: Further clarification for your comment
You can picture the recursive calls like this:
-- assuming elem' is defined as:
elem' _ [] = False
elem' x (y : ys) = if x == y then True else elem' x ys
-- calling elem' trying to find 6 in [1..5]
elem' 6 (1 : [2, 3, 4, 5]) = if 6 == 1 then True else elem' 6 [2, 3, 4, 5]
elem' 6 (2 : [3, 4, 5]) = if 6 == 2 then True else elem' 6 [3, 4, 5]
elem' 6 (3 : [4, 5]) = if 6 == 3 then True else elem' 6 [4, 5]
elem' 6 (4 : [5]) = if 6 == 4 then True else elem' 6 [5]
elem' 6 (5 : []) = if 6 == 5 then True else elem' 6 []
elem' 6 [] = False