How do I stop laptop from underclocking?
If you don't want your CPU to throttle down you need to enter the BIOS and disable either Intel "SpeedStep" or AMD "PowerNow!" technologies. These lower your CPU power when its not being used so your computer uses less power, produces less heat etc.
In other words your CPU is slower when you are not using it and speeds up when you need it to.
For a laptop I would recommend leaving it on unless you always have it plugged into the wall and the area it is in has good air circulation.
I recommend you to check the temperature of the computer CPU, it could be due to overheat.
I do not know how old is your laptop, but they tend to catch dust really quickly. So if the diagnostic is correct, you may want to clean it a bit to recover full air circulation within the case.
BTW the monitor says you are using 31% of maximum frequency, not that the maximum frequency is 31% of the nominal.
It's not "underclocked" as modern speed step and PowerNow can scale the processor as needed extremely quickly, to the point that it does not affect the performance of your programs.
What is more likely is that your computer is underpowered for what it is you are expecting it to do, or there are unnecessary applications running on the system that can or should be removed.