I agree, only a fool, delusional ideologists or a delusional religious zealot will think religion matter in geo politics. Every country is out there for their own selfish national interests and furthering their country's influence by all means necessary. Turkey is supporting Azerbaijan for its own interests, Iran is close to India(a Hindu country who has been fighting their fellow Islamic country for decades.lol) and Russia(an atheist/orthodox country officially) for its own interests as well, Saudi Arabia is also in Yemen a fellow Islamic country and against the Islamic Muslim brotherhood in Egypt for its own interests as well. Western countries have also been allies with many Muslim/Arab countries from the gulf to Turkey to Pakistan to Malaysia , China one of the most atheist countries on earth and with a religion which Muslims might consider idol worshippers is Islamic state of Pakistan's closest allies for decades now Etc etc.
Thing is :INTERESTS TRUMP EVERYTHING IN GEO POLITICS. If a country believes cooperating with another country will serve its interests ,they will do just that irrespective of religion.
People should stop living in this islamic mullah bubble. Lol So I see nothing wrong for Iran(and Russia) siding with Christian Armenia against Muslim Azerbaijan, if Iran's interests are better served doing that, then so be it.