Code executes from top to bottom. Look later in your code, you change the animation again if you aren't moving. This means that you are indeed doing the animation, but then you immediately change it to something else.
Try adding a boolean variable to your player called "Attacking". When you start the attack, turn "Attacking" on, and when your attack finishes, turn "Attacking" off.
Then, at the bottom, make your idle animation happen if the player is not moving AND if the player is not attacking.