To make your post easier to read, you can click on the # icon at the top of your typing area and choose CODE, which will give the begin/end symbols for a code block, and you can post your code between them, and it is easier to read them.
%canalescom($nick) is the wrong thing to do. This currently is a blank variable that does not exist, so it is a blank string. If it did, then the returned value would be executed as a command. You probably intended $canalescom($nick) which executes the alias while passing the $nick to it as the $1 parameter. However, because I am changing the alias to return a string, you do not want to execute the alias because it would then execute the returned list of channels.
However, when your canalescom alias executes, you are using $me instead of $1, so you are finding the common channels you share with $me (yourself), so $comchan($me,1) is always the same as $chan(1).
Also, instead of having the value being something that is returned from your alias the same way that $comchan returns something to you, your alias tries to create a global variable inside a loop, but your alias is also unsetting the variable inside the loop, and also there is a /return inside the loop, so it can never execute the loop more than 1 time.
Note how the new alias now does not use a global variable, and instead uses /return to send the answer back to the caller. This makes it more flexible, where the caller can echo the results without needing to unset a global variable. If it wishes to, the caller can make it become a global variable like
/set %global $canalescom($nick)
on *:OPEN:?:{
mensajes
}
alias mensajes {
echo $nick CommonChannels: $canalescom($nick)
echo $nick Days:
}
alias canalescom {
var %i = 1 , %total $comchan($1,0) , %list
while (%i <= %total) { var %list %list $comchan($1,%i) | echo 2 %i $comchan($1,%i) | inc %i }
return %list
}