How do I make frames on a single sprite disappear when inactive?

I’m completely new to game design and I’m having some trouble with a simple problem. Apologies if this has already been asked, but I couldn’t find anything similar.
I have two player animations, idle and walking, that always overlap. How can I make the idle animation frames disappear when the walking animation plays? Do I need to create a script? If so, how do I do that?

Images below for reference.

Take a look at this Unity - Manual: Animator Controller and this Unity - Manual: Animation transitions
I think that you have a Transition Duration setted (Under Animator → Select the transition between idle animation and running animation → Settings → Transition Duration). Set that value to 0 so you have an instant transition