You have both actions set for chans where you are not opped, is that what you want?
Code:
allchans {
  var %i = 1
  while ($chan(%i)) {
    if ($me !isop $v1) { os mode $v2 +o $me | mode $v2 + $+ $1 }
    inc %i
  }
}

Or for the mode change to act on all chans
Code:
allchans {
  var %i = 1
  while ($chan(%i)) {
    if ($me !isop $v1) { os mode $v2 +o $me }
    mode $v2 + $+ $1
    inc %i
  }
}