The Loma Prieta Earthquake struck San Francisco, California (US) in 1989. It was a magnitude 6.9, and just 63 people died, 42 of them from a single incident in which a highway overpass collapsed.
The US and Japan are both first-world countries with strong building codes (or so I thought). So why the vastly different body count for these two apparently similar earthquakes?
The Wikipedia article cited in the OP compares the Hanshin quake to the Northridge quake in the US (not Loma Prieta) and has this to say:
The takeaway: the soil substrate made some of the difference, but a large part of the problem was old, pre-existing buildings not brought up to the modern building code (which had only been promulgated 13 years before the quake.)