You connect your XMPP client to your server, but you can add contacts from Google's server and communicate with them.
Federation is a very important interoperability idea in XMPP. It's a shame that some major XMPP servers (like Facebook's) don't use federation making them isolated and defeating the whole point of XMPP.
And some are even worse non interoperable and insecure monsters (Whatsapp). It's really strange that such kind of stuff comes out in this day and age.