The population of Israel approximately doubled from 1949 to 1965. It did so because of immigrants from places like Egypt, Iraq, and Yemen.
The overwhelming majority of those immigrants were not voluntary, but were forced to leave by formal expulsion (Egypt, semi-formal in Iraq); revocation of citizenship (Algeria, Libya); massive official discrimination (eg Syria); or simple mob violence (Libya again, Tunisia, Morocco). In Egypt there was a wonderful trick of forcing expellees to sign papers saying their departure was "voluntary".
In countries where only mob violence was involved (Morocco, Tunisia), some Jewish communities remained. Then there's the interesting Lebanese case, where the Jewish community thrived until targeted during the civil war.
But yeah, don't pretend that the complete nonexistence of Jewish communities in Yemen or Iraq or Egypt happened by chance.