Safari does not respect the operating system’s DNS settings, it uses its own. I have seen several reports online that you can disable this behaviour by turning off iCloud Private Relay or disabling Advanced Tracking and Fingerprint Protection, but was never able to do so with various combinations.