It could be anything from an unintentional malware installation to a hardware bottleneck or failure. Some things are fairly easy to fix.
Please run an EtreCheck evaluation of your Mac. EtreCheck is a safe and highly regarded utility from a trusted developer and respected ASC contributor. The diagnostic app gathers important info about your hardware and software and reports it back to you. The EtreCheck report will not include any personal info. It simply gathers specifics about hardware and performance and installed software that might be in conflict with the OS.
Please navigate to EtreCheck.com and download the free version. Be sure to Allow Full Disk Access when you install the app. Once you’ve run the app and created your report please post it with your reply to this message.
You must upload the full report. To see how, please click > How to use Add Text when posting… EtreCheck Report.
We’ll use your EtreCheck report to look for the things that may be causing your problem and advise how to correct them.