Just to add to this horrible experience - I had the same problem on a new Dell latitude 5530 laptop, Windows 11, with Realtek audio. I had all the "Enhance audio" settings turned off, as above, and no additional audio software - I didn't have Dell Optimizer, or the Dolby one, or the Realtek console - nothing at all. And recording in audacity would record my voice, but not my guitar. The quick test is just to record your voice, and then clap a couple of times. Audacity would capture the voice, but not the claps.
I eventually solved it by *installing* Dell Optimizer for the first time, and then disabling all of the audio enhancements in Dell Optimizer. There is also a master enable/disable button at the top which I disabled for good measure. And then audacity recorded claps and my guitar as well.
Somehow, the echo cancellation (or whatever it is) was activated in an invisible way that wasn't possible to turn off without using something like Dell Optimizer. Is that a Windows 11 bug (ie, disabling the enhancements should disable whatever audio "correction" was happening, but it doesn't) that Dell Optimizer by chance fixes? Very unclear, but that has prevented me using this laptop for audio for its first year of life.