Change "activate" to "run" to make the script run in the background. also add "quit" to the end of the script with a delay of 0.6 to quit system preferences after executing the script.
tell application "System Preferences"
set current pane to pane "com.apple.preference.trackpad"
tell application "System Events"
tell process "...
I ran into the same problem and seems to me its because of spotify. In the past VS code would cause this overload of the system and the programmers patched that bug.
Check this out - https://github.com/Microsoft/vscode/issues/14685
If not, it would be a malware - worst case.