"Under U.S. law, use of a competitor's trademark in accurate and non-deceptive comparative advertising is legal and does not constitute trademark infringement" [1]
Which shows that it is a fairly grey area. "Fair use" doctrines apply to trademark infringement and using your competitor's name in this way has in the past been allowed.
It's legal, but I don't understand why. The broader discussion point is why we do this to ourselves.