Without a reprex, it's not immediately obvious to me even what the connection is between rep and the window of a kNN model. However just in terms of what the function rep does, your lecturer is correct.
rep(1:5, each = 4)
#output: 11112222333344445555
The first argument to rep is the vector to be repeated, and "each" determines how many times each element is repeated. Alternatively using "times" you get:
rep(1:5, times = 2)
#output: 1234512345
As for why you have increased accuracy with a smaller window--are you measuring training accuracy or test/validation accuracy? The accuracy of kNN will monotonically approach 100% on the training set as you decrease k