I don't believe that they use the Thunderbird's configuration data obtained from their end users and put that into their database -- that would be a pretty intrusive thing from the privacy point of view. The TB's documentation on autoconfiguration describes how they obtain the configuration data.
For the other part of your question, have a look at RFC 6186 which uses the DNS SRV
records for specifying the IMAP server to use (and with TB, it's bug 342242.