The behaviour depends on a few preferences:
* network.trr.mode can be set to 0 (disabled), 1 (race native vs TRR), 2 (TRR first, OS DNS as fallback), 3 (TRR only), 4 (run native and TRR in parallel but use native results, save TRR timings for telemetry), or 5 (off by choice)
* network.trr.uri configures which DoH endpoint is queried
Firefox does maintain a DNS cache, even if you use the native DNS resolver. You can view the cache at about:networking#dns.