This is because a stream of all public data from all apps is being subscribed to by all apps. Whatever you care about, you save into your app’s database. Each app’s database serves as an app-specific index of the data on the network. If you want to query Bluesky posts later, you just save them as they stream in.
So every app can piggyback on data created by other apps. And anyone can run a "retransmitter" (aka a relay) like this. It's an application-agnostic aggregator over websockets. The one operated by Bluesky-the-company is most popular one, but https://atproto.africa/ is another one, and you can get one running yourself for about $30/mo; the implementations are open source.)
I explain this in more detail in https://overreacted.io/open-social/, Ctrl+F to "to a stream that retransmits events from all known repositories on the network".