Neither on QUIT nor on NICK have a $chan associated with them. In order to correctly place them in the channels where they "occured," you must loop through $comchan($nick,%i), and then halt the default text. For example, follow these examples and modify them to suit yourself.
Code:
;
on ^*:QUIT:{
  ;
  ; Create a clean quit message surrounded by parenthesis if a quit message has been supplied. This
  ; lets us maintain mIRC's use of parenthesis but allows for a network that doesn't force a quit message.
  if ($1-) var %Quit.Message = ( $+ $1- $+ )
  ;
  ; Prepare to loop through each common channel you shared with them, starting with the first channel.
  ; We know we share at least one channel with them because we would not have seen the QUIT (or,
  ; below, the NICK) event.
  var %i =1
  ;
  ; While there are more common channels, keep echoing.
  while ($comchan($nick,%i)) {
    ;
    ; This particular echo imitates mIRC's own quit, so modify it to suit yourself. The echo flags make the
    ; echo behave the way any normal mIRC quit message would echo based on the user's own settings.
    ; $ifmatch will return the name of the channel that was found in the while condition, so that is where
    ; we will echo the quit to.
    echo $color(quit) -lbfti2 $ifmatch * Quits: $nick ( $+ $address $+ ) %Quit.Message
    ;
    ; Go to the next channel.
    inc %i
  }
  ;
  ; Echo it to their query window, if you had one open to them when they quit.
  if ($query($nick)) echo $color(quit) -lbfti2 $nick * Quits: $nick ( $+ $address $+ ) %Quit.Message
  ;
  ; Halt mIRC's default quit message.
  haltdef
}
;
; The same comments apply to on NICK as are shown above in on QUIT, so they will not be repeated.
; This will also give you a better idea of what the script looks like without all those pesky comments!
;
; If you don't care to echo nick changes to their query window, comment out or delete the IF line above
; the haltdef. Also, there is no %Nick.Message.
;
on ^*:NICK:{
  var %i = 1
  while ($comchan($nick,%i) {
    echo $color(nick) -lbfti2 $ifmatch * $nick is know known as $newnick
    inc %i
  }
  if ($query($nick)) echo -lbfti2 $nick * $nick is now known as $newnick
  haltdef
}


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C