The most basic way to manage animation states in Unity is by setting parameters. Each state in the Animator can have a set of transitions to other states, and each transition can have a list of conditions, telling it when the state should change. By creating a parameter it becomes very easy to set up a condition to be triggered when something happens in a C# script.
In this basic example, Walk is a Boolean parameter used as a condition in the animation controller between walk and idle states. You can, of course, set up all sorts of intricate state changes, including blend trees in an animation controller, but this basic means of triggering transitions stays pretty straightforward and will probably get you a long way toward having something playable that looks good in terms of playing your animations at the right times.