% (modulo, remainder after division) https://www.scirra.com/manual/78/expressions
eg
0%4 = (0*4)+0 so returns 0
1%4 = (0*4)+1 so returns 1
2%4 = (0*4)+2 so returns 2
3%4 = (0*4)+3 so returns 3
4%4 = (1*4)+0 so returns 0
5%4 = (1*4)+1 so returns 1 etc etc
Note: animationframe can't be < 0 that's why you must add animationframecount before substract 1 to animationframe on 'left arrow pressed' condition