This is a common problem (something happening once every frame instead of just once) you need to solve in game programming. It's not specific to Unity or Spine. But it's something basic that you'll eventually need to understand going forward in programming.
For every programming problem, there are many good solutions, and many more bad ones. You'll eventually need to get a firm grasp of basic concepts and bigger pictures for you to be able to arrive at the best possible solution that works for the bigger structure of your game's code.
Here's one solution:
SkeletonAnimation anim;
public float speed = 1.2F;
bool isWalking;
void Start ()
{
anim = GetComponent<SkeletonAnimation> ();
}
void Update()
{
float translation = Input.GetAxisRaw("Horizontal") * speed;
translation *= Time.deltaTime;
transform.Translate(translation, 0,0);
if (!isWalking && translation != 0)
{
anim.state.SetAnimation (0, "walk", true);
isWalking = true;
}
else if (isWalking && translation == 0)
{
anim.state.SetAnimation (0, "idle", true);
isWalking = false;
}
}
Note the places where isWalking was added.
The original code was calling SetAnimation every frame, which causes the animation to keep going back to the beginning. What needed to be done was to make sure SetAnimation gets called only once when you start or stop pressing the character's walk buttons.
To achieve this, I introduced a boolean variable that stores a certain state of the character, and incongruence check for the state of the character and the button you're pressing. It will remember that the character is already walking from the previous frame, so it won't call SetAnimation again. Likewise for idle.
There are many better ways to solve this problem but the best one depends on what your character's code needs to do and, again, the larger structure of your game's code.
Keep practicing and good luck!
Also, you started on the right foot. Stick with C#.
UnityScript/Unity-JS is less powerful and also a huge mess.