Different implementations will work differently, but they essentially use follow lists to collect & aggregate notes from their own and other relays + various degrees of separation, or other criteria. They are paid services. They have pros & cons, like anything else. For examples, they can have a centralizing effect & miss notes that are published to/by lesser known relays/new users. They also can reduce the number of connections, data consumption & spam.
Discussion
Are they all paid services? I'd like to try one for free 😅
I have not seen one that is completely zero cost. You'd need to look into their use policies, maybe some offer trial periods or something. I'm not sure.
Found this for self hosting, but not maintained it seems https://github.com/bndw/nostr-relay-proxy