It’s complicated, but as far as I understand it…
Regarding the white “robe”.
It is generally just in the Gulf states that you see it. They call the Persian Gulf Al- Khaleej. They call the outfit dishdasha.
You never see it in North Africa or that area that some people call The Levant.
They nearly always wear it when they are going to a mosque, or if they are making a pilgrimage to Saudi Arabia.
Otherwise, it seems like the choice is sort of arbitrary depending on the wearers sense of tradition, how strict the local standards are (very strict in Saudi) or the occasion.
There is a formal version or a casual version too-sometimes they button the buttons, sometimes they leave it open.
They are comfortable in the heat, so there is a practical reason as well.
Regarding the head cloth…
It has a different name, depending on where you are.
The other places in the Middle East not just Khaleej, the men wear the headcloth as an accessory, even with more Western style clothing. And there are about half a dozen different ways to wear the headcloth depending on the occasion. And the kids, especially in the more oppressive Gulf states, have their own subtle little way of wearing it as a form of rebellion/self-expression, sort of like the way Western kids change their hair style.