Curious. So IE has trouble rendering it as intended, but Firefox and Safari manage to sort it out.

IE probably ignores anything after it finds an illegal character (the "<") inside the "<a ... >" construct and just processes the good stuff.
Meanwhile, Firefox and Safari (being a bit backward

) appear to scan ahead to find a closing ">" for the construct, then work backward to find the previous "<". Or maybe they work forwards but ignore the "... <a " portion after the end of the first href, then decide that the second href overrides the first href. Who knows.

But I wouldn't say that they "manage to sort it out" - just that they end up with the answer that we, as regular users of this page, expect
in this particular case - but probably from luck rather than through design.
Anyway, its a classic garbage (which invalidly constructed html code is) in, garbage out situation.