@Wayne_Sutton has the right idea. It’s a histogram matching algorithm in essence. No lookup in a database or something like that.
Edit: there seems to be no information on the button on Rawpedia. This is in dire need of documentation, as per Document Auto-Matched Tone Curve · Issue #4951 · Beep6581/RawTherapee · GitHub