You are not supposed to create the connections between your animations in a script. What you do is you create the connections in the Animator and set up variables for if you are standing or walking and in which direction you are going. Then you just edit these variables in a script and the Animator takes care of chosing the right animation.
This video shows it in action: Example
(you see the connections and in the bottom left the variables he set up)
Quick google of "mechanim 2d tutorial" gives you: Tutorial
edit:
Too long for a comment :)
Basically what i would do is create 2 variables, one bool named "Standing" and one Integer named "Direction". Then you make one connection from AnyState to every other state you have(Rightclick on AnyState to make the transitions). Maybe order them in a circle around AnyState.
After this, click on the connections and in the Inspector set the conditions by chosing "Standing", then add one more and set it to "Direction" "Equals" and the number for the direction.
Then in your script somewhere in your Update function you might have something like:
private readonly int UP = 0;
...
if(speed.magnitude > 0.0f)
Animator.SetBool("Standing", false);
else
Animator.SetBool("Standing", true);
if( Condition for walking up? )
Animator.SetInteger("Direction", UP);
if( Condition for walking down? )
Animator.SetInteger("Direction", DOWN);
...
this might not work directly, but you get the idea. You might want to use a switch for the direction depending on how you set it up.