Sounds like a misconfigured animation, perhaps with root motion enabled when it shouldn’t be, or something else animated, or some incorrect state.
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 on how to do that: