If I understand it correctly, only the link in the first item is correct ?
By the looks of it, the first instance in the loop gets the value from $term_link. Every item after it copies the link from the first instance, since it’s not ‘overridden’.
I don’t know how your repeater is setup, but instead of $term_link I expect you would either use something like $row[‘term_link’] since it’s part of the repeater.