Gharb doesn’t come from the word gharib. Rather, they come from the same root. Semitic words are derived from triconsonantal roots that have meanings that influence the words that develop from them. Gharb comes from the gh-r-b root, which gives words that mean west, sunset, desert, mingle, stranger, foreigner. The Arabic word Maghreb (place of sunset/west), which refers to North Africa, & gharaba (to set - as in the sun setting), comes from this root. So do the Hebrew words ‘arav (desert) ‘erev (mix of people/strangers), maariv (evening), ma’arav (west) & others.
The word Arab itself comes from this root.
The west was named al-Gharb because of the western/setting sun meaning of the root. Not because of the cognate word strange.