I see a few things that look wrong, but I'm not sure if that is your issue.
if position.distance_to(target) > 10:
velocity = target - position
target = position
You need to set target equal to position after reading the value (or on touch up) otherwise it will continue to move even when you let go of the screen (unless that is what you want).
if velocity.length() > 0.001:
Never check for zero or hard-coded values when using floats. Always have some epsilon (a small margin of error) otherwise it won't work. Same reason you can't check for not equal to zero below:
if abs(velocity.x) > 0.001:
...
elif abs(velocity.y) > 0.001:
Finally, this line might be repeatedly setting the animation to the first frame (in which case it would look like it's not working but it's just repeating the first frame over and over):
if velocity.length() > 0:
velocity = velocity.normalized() * speed
$AnimatedSprite.play()
else:
$AnimatedSprite.stop()
It might be best to put the animation play code somewhere else (for example, in your _input() control code you can check for touch press and touch release and do the animation play/stop there instead).