Code:
alias loopservers {
  var %i = 1
  echo -a Number of servers $scon(0)
  while (%i <= $scon(0)) {
    scon %i
    echo -a Server number $+(%i,'s) cid is $cid
    inc %i
  }
}

/loopservers
Number of servers 2
Server number 1's cid is 1
Server number 2's cid is 4


Were u using /SCID to change servers?
Using /SCID N to change to a specific server should only really be used when you already know the $cid of that server since $cid is the N value.

If your wanting to loop through each server use /SCON N it uses 1 to N for the server numbers, the $cid's well be set according to each connection, in my case the cids were 1 then 4.
Note. I had just started mirc, so i assume the $cid value is not always dependent on server connection order etc, but rather is a unique Conection IDentification number.