alright. i tested your code. my version of it now works as intended.
first, add a idle frame to the fire animation at the end. lets say that frame's number is N.
this frame signals that the animation finished. you can just replicate the last frame instead.
now you can use the test:
if $AnimatedSprite.animation == "attack" and $AnimatedSprite.frame != N:
pass
else:
move_direction =0
$AnimatedSprite.play("idle")
the other thing that caused you being stuck in place is that this if statement needs to be on the end of the movement loop.
so the correct loop would be:
if Input.is_action_pressed("ui_right"):
move_direction = 1
$AnimatedSprite.flip_h = false
$AnimatedSprite.play("running")
elif Input.is_action_pressed("ui_left"):
move_direction = -1
$AnimatedSprite.flip_h = true
$AnimatedSprite.play("running")
else:
if $AnimatedSprite.animation == "attack" and $AnimatedSprite.frame != N:
pass
else:
move_direction = 0
$AnimatedSprite.play("idle")
hope this helps.