Don't look for precision in the matching of IATA city to airport code. There are actually not many good matching ones left, if somewhere else got there first (and this would have been a long time ago) then those choosing the codes have to come up with something else. One of the features of DXB and (particularly) LAX is that they have actually turned out more memorable than if they had been plain DUB or LOS (both used elsewhere). You will generally find that (comparatively) newer airports have gone for the more contrived codes; LAX was not the original airport of Los Angeles, pre-war airlines used Burbank, while Dubai was actually one of the last Gulf points to get an airport, previously it was served by Sharjah close by. YYZ for Toronto Pearson is a particularly tortuous bit of logic to explain, which I actually did on another post some time ago.
http://www.pprune.org/spectators-bal...ml#post6077263
Sticking with codes for cities which have changed name is common, there being no easy way to change them without all sorts of errors arising, hence St Petersburg in Russia remains LED for example.
In the professional aviation world separate 4-character codes devised by ICAO are used instead. Thus London Heathrow LHR is EGLL in that sequence, which most of the posters here would be more familiar with. There is logic there as well, but to a geographical pattern, not based on a mnemonic of the city name.