The easiest way to cause problems with macOS and the proper operation of your computer is to install anti-virus, optimizing, cleaning, security and/or VPN software. If you are running any of these the best thing to do will be to uninstall them. Apps of these types do nothing positive for the Mac that macOS cannot do.
Otherwise, see if the problem still happens in safe mode. Safe mode will often correct weird software behavior by forcing the OS to clear caches, do disk repair and other self-maintenance and housekeeping and temporarily disables third-party mods. Sometimes just running the computer in safe mode for a little while can clear up weird behavior.
How to use safe mode on your Mac - Apple Support
Does the problem go away in Safe mode?
If so, this may indicate an OS software conflict with your apps.
You can exit safe mode by restarting your Mac normally, then reevaluate the problem.