XMPP lost because there was no big player behind it willing to push it as far as possible under its public name. Only a community of enthusiasts and a steering committee that only cares about what is going in the next spec.
Matrix at least has a company pushing for it, so there's a better chance it'll have more success than XMPP; unfortunately we'll have to wait a few more years to see the difference.
I don't think XMPP "lost" because it was bad technology. AFAIK the big players are still using it in various places under the hood. It lost because big players want to build "ecosystems".