Perhaps you have Write Defaults (x)
checked in your animation state?
Otherwise, here’s how to untangle code / animation:
Anything with Animations / Animators / Mechanim:
Only consider the code AFTER you have done this critical step:
Always start with the Animator state machine and prove it works in isolation, no code at all.
Here’s more reading: