The animations in the new APIs reset when called multiple times. Instead of calling it every frame, you should only call it once when you start moving left or right:
Alternatively, I made an extension to make this sort of thing much easier. If you add this extension to your project:
riknoll/character-animations
You get blocks that capture this behavior along with a few other common scenarios:
It’s on my to-do list to get this in the default extension list.