That is difficult to answer.
Basically, this, "Al" prefix means "The". For Jerusalem, Al-Quds in Arabic literally translates to, "The (location of) Holiness". The Arabic language identifies Jerusalem as the place of holiness, hence the need to put the "Al" in front of it.
But why do we refer to Alexandria as, "The Alexandria" and Barcelona just as it-self? I'm not really sure.
What I'm assuming is that because Alexandria was the capital of Byzantine Egypt at the time of the Arab conquests, it was seen as an important location, which could explain the need to put, "The" in front of it. But that doesn't really make sense, because Makkah is considered just as important but it doesn't have that prefix.
The locals in Egypt just call Alexandria "Iskandariyya", without the prefix, just so you know. I hope that cleared some things up -)