FYI, you have a fourteen day window to return the computer for a refund if you bought directly from Apple.
Otherwise, there are some things you might do to troubleshoot this problem.
To begin, if you've installed any sort of anti-virus apps, cleaners, optimizers or VPN software you should uninstall those. They are not necessary on the Mac and often they do the exact opposite of what they are marketed to do and compromise the performance of the machine.
For more info, please see these support documents:
Effective Defenses Against Malware - Apple Community
Another thing to try will be to reboot the computer in safe mode.
How to use safe mode on your Mac - Apple Support
Safe mode will often correct weird software behavior by forcing the OS to do disk repair, clear caches and other housekeeping and temporarily disables third-party mods.
Does the same issues remain while in Safe mode?
You can exit safe mode by restarting your Mac normally, then reevaluate the problem.
If a safe boot has no apparent effect, then you might try reinstalling macOS.
Reinstalling macOS doe not have to erase or compromise your user data at all, but it's always best to have a Time Machine backup or otherwise copy of your data before doing so.
Review carefully and follow the guidance for reinstalling macOS found here: How to reinstall macOS - Apple Support Do not erase, partition, format or otherwise alter the startup disk for this exercise.