Understanding In-Context Learning from Repetitions