The enemy is only going right because of a domino effect.
Try checking for states with a cooldown, or you can implement it just like how I implemented it by checking for an instance variable when the player/enemy is in collision with a flip object (See the GIF below):
