As has been mentioned QuickTime Player won't easily record audio when it makes a screen recording. It can be "tricked" into doing so. I haven't tried this process though and previous efforts to do some of the steps involved have proven unreliable on some OS versions.
I'm using a third-party program called
Capto. It can do what yuo need and I'm sure there are others.IIRC they have a free demo so you can try it before purchasing.
There are a couple of things that you need to keep in mind when using this program:
1. Let it install the Boom 3D audio software. IIRC that is what's needed to record the system sound.
2. Capto saves the video in a format that opens in the Capto video editor. If you want to use the video in QuickTime Player you can export it into an .mov or mp4 file. The process isn't difficult but does add a step.