Why did some Arabs decide to stay in Israel in 1948 while others fled What differentiates these two groups ?

The main bulk of Palestinian refugees were created through the ethnic cleansing of Palestine at the hand of Zionist militias between 1947-1948 and the subsequent establishment of the state of Israel. This campaign of ethnic cleansing took place before and during the war of 1948, and saw approximately 800,000 Palestinians expelled from their homes, and over 530 villages being demolished. Another large wave of displacement and expulsions followed the war of 1967. Israel depends upon the displacement of these refugees and their descendants to maintain itself as an ethnocracy.
The small minority of Palestinians, about 160,000, who had managed to avoid expulsion and remained in the part of Palestine that had become Israel were now citizens of that state. Israel’s government, dedicated above all to serving the country’s new Jewish majority, viewed this remaining population with deep suspicion as a potential fifth column. Until 1966, most Palestinians lived under strict martial law and much of their land was seized (along with that of those who had been forced from the country and were now refugees). This stolen land, an expropriation deemed legal by the Israeli state, including the bulk of the country’s arable areas, was given to Jewish settlements or the Israel Lands Authority, or placed under the control of the JNF, whose discriminatory charter prescribed that such property could only be used for the benefit of the Jewish people.
For various reasons, such as a commander’s decision during war, or the location of a village, or just by pure chance, some Palestinians were not ethnically cleansed during and after the establishment of Israel. It is estimated that around 80% of the Palestinian population within the green line were expelled. The remaining 20% would live under martial law for decades to come, and have their communities turned into segregated, heavily controlled enclaves surrounded by barbed wire. Between 1949 and 1966, those Palestinian Arabs were governed by military rule and subjected to travel permits, curfews and detention. They were also expelled from their homes and land, which were often given to Jewish settlers or state-backed bodies.
This does not mean that the spared population had sided with the Zionist forces. For example, the city of Nazareth was spared because the Zionist commander thought that ethnically cleansing such a large amount of Palestinian Christians at the same time would look bad for Israel. However, ethnically cleansing smaller Christian and mixed villages around Nazareth and elsewhere was fine.
It should be noted that the destruction of Palestinian villages had nothing to do with whether they participated in the war of 1948 or not. Neutral villages with non-aggression pacts with the Yishuv were also ethnically cleansed.