Your Tor software comes with a list of predefined directory authorities. These authorities maintain signed lists of relays from which your client can choose to build the connection. A new relay publishes a server descriptor to the authorities to advertise itself.
Since not every Tor client acts as a relay, the number is smaller than you might assume and you don't need to somehow aggregate the node list yourself.
The FAQ explains this pretty well:
Coordination: How do clients know what the relays are, and how do they
know that they have the right keys for them? Each relay has a
long-term public signing key called the "identity key". Each directory
authority additionally has a "directory signing key". The directory
authorities provide a signed list of all the known relays, and in that
list are a set of certificates from each relay (self-signed by their
identity key) specifying their keys, locations, exit policies, and so
on. So unless the adversary can control a majority of the directory
authorities (as of 2012 there are 8 directory authorities), he can't
trick the Tor client into using other Tor relays.
You can explore the bridges and relays at Atlas or Globe.