The war in the Middle East is extremely difficult to unravel or understand. Basically the region has three Muslim power centres: Turkey, Iran and Saudi Arabia. In addition, there is Israel which also has a very powerful military, but in the present phase is mostly staying in a defensive mode. These four powers are all mutually hostile. The three Muslim powers all have alliances with lesser powers in the area and also support irregular forces that conduct guerrilla warfare on their behalf.
As if this power struggle were not enough, there is also an ideological battle of considerable complexity. The region is divided into Sunni and Shia Muslim, Iran being Shia, Turkey and Saudi being Sunni. There are many other religious groups in the region, including the Alawite sect to which the leader of Syria belongs. Even within the Sunni majority there are sharp differences based on different interpretations of the Koran, ranging from puritanical (Saudi) to relatively liberal (Turkey). The Al Qaida group, for instance, is strict Sunni, but originally came into existence around disputes over the culture and leadership of Saudi Arabia which is a different kind of strict Sunni. Nothing here is simple.
Then, on top of all this, there is the interference of outside powers, most notably the USA and Russia. Here too there is a complex interweaving of economic exploitation, power politics and ideology, quite a bit of it not consistent.
An illustration of all this is the present crisis over Qatar. Qatar is a Sunni country that has been sent to Coventry by a consortium of other Sunni countries led by Saudi Arabia and Egypt because of its support for the Muslim Brotherhood, a Sunni political organisation that Saudi and its allies regard as terrorist. Not long ago the Brotherhood was running the government in Egypt having won an election. That democratically elected government was overthrown by a military coup that was approved, possibly aided, by the USA (so much for freedom and democracy). Immediately following the isolation of Qatar, its big Shia neighbour, Iran, offered support and is shipping food supplies to replace those cut off by Saudi. Turkey has also offered support to Qatar and is probably going to send troops. This, in effect, in this instance, puts Sunni Turkey in alliance with Shia Iran against the Saudi faction. However, in Syria, Turkey has for long been an opponent of the Alawite government which is supported by Iran, thus putting Iran and Turkey on opposite sides.
In theory, Turkey is a member of NATO and thus an ally of the USA. The USA's closest ally in the region, apart from Israel, is Saudi (an autocratic monarchy without even a slight shade of freedom or democracy). Thus in that context Saudi and Turkey are allies, opposed to Iran. However, Turkey has recently been moving closer to Russia. Yet Russia, in alliance with Iran, supports the Syrian government. The USA regards Iran (one of the relatively more democratic countries in the area) as the arch villain. We could go round and round these complexities almost indefinitely, and I have not even mentioned Islamic State or Afghanistan.
In some ways, the simplest player to understand is Russia. Russia is a long standing ally of Syria. There have been Russians stationed in Syria for many years and many have families there. After the so-called colour revolutions in other parts of the Arab world, Russia decided to draw the line at Syria and do whatever it took to prevent the same thing happening there. This conveniently put them in a tacit alliance with Iran. Since then they have been trying to resist the rebel forces in Syria that are supported by the USA and, wherever possible, build other alliances in the area. Thus relations between Turkey and Russia have improved steadily as Western disapproval of the Turkish government has grown. This, however, puts Turkey into an ambivalent position.
Turkey is trying to avoid coming down firmly on one side or the other in its relations with the USA and Russia but events are pushing it into the Russian camp and the current Qatar crisis is just the latest of these. Trump's visit to the region has had some polarising effect, which has probably contributed to the present stand off over Qatar - Trump having even claimed credit for it - but is not so extensive as to simplify the age old complexities very much; indeed it adds new ones.
If it were not for the dire seriousness of a situation in which large numbers of ordinary people are getting shot, bombed, starved, driven into exile, raped, and made homeless, one could see the whole thing as not unlike a Chekov farce.