Why do many Muslims consider Russia their friend?

I guess that is the main case. Another issue is that after Afghanistan 1979-'89 these states are afraid of Russia.

Perhaps many Iranians understand that their government has allies which are worse then enemies.

Rather a lot of wishful thinking, from what I have seen.