Hello,
I've made a free tutorial that shows how to control unity animations in script using enums so you can skip creating messes with animation states. Below is Part 1 : a basic state machine using bools & if statements, which is easy to understand for new programmers, and a second version in part 2 using enums which is a bit more sophisticated but still manageable. I hope these tutorials help you in your game dev journey!
Have a great day! Best of luck on your projects!