How does it all technically work? I've been having trouble lately but I think I'm looking at it all wrong.
Federation, which is what
stellar.toml is usually used for, is a layer on top of Stellar, and nothing that Stellar itself "uses".
Client applications, typically, look at an account they are interested in, find the homedomain, and use it to build a URL, hopefully pointing to a valid stellar.toml.
If it does, this can be used for finding out meta data about an account. If it's an issuer, there might be information about the assets issued, or information about the issuing organization.
If it's a regular account, and it has a federation server listed, it can be used to find a federated address.
Similarly, with a federated address, you can look up the stellar.toml of the associated domain, and find out the account its corresponds to.