(disclaimer: I'm sacrificing correctness for understandability here)
You need to make sure that your sound card is treated as a loopback device.
A soundcard takes an input signal, transforms it and outputs it as a different signal. E.g. it takes an analogue signal and will transform it to a digital one (or vice versa).
When a system sound is a triggered it is sent as a digital signal to your soundcard, which will turn it into an analogue one before output. If you hit "record" in audacity it will try to record the analogue source, but there is no analogue source, hence your audio wave will be flat (i.e. no signal)
So, to be able to record the system sound your sound card needs to actually do 2 actions: transform it to an analogue signal and then record that signal. I.e. it needs to loop back the result of the transform to itself before it can record it. That's why it's called "loopback device".
So, what you need to do in audacity is to select Windows WASAPI as your audio host and select your soundcard as a loopback device. E.g.
Depending on your machine it might have other options than Realtek(R) Audio (As you can see I also have an external soundcard a Focusrite, which I'd be really using if I'd want to record system sounds)
Realtek Audio is the standard sound card driver which comes out of the box with Windows 10.