Don't install social-media-app-games.
Don't click links in emails, at all.
Don't install "free" software that doesn't come from an extremely reputable source.
Don't follow junk links on the web or click ads and have your browser security cranked up a little to avoid auto-accept stuff (like cookies).
That will solve 99% of any issue before it even begins.
If using Windows, just using their Essentials and keeping updates on your OS up to date will take care of most obvious exploits.
As for an EMP-like attack from a solar CME, the last modern recorded one that was serious happened in 1989 and knocked out a big part of Canada. Today, using a physical hard drive, your power would go out, but the case and the shell around your HDD would actually protect it for the most part from even a serious pulse. Your SSD if exposed would probably lose information. If something like this truly seriously happened and was powerful enough to go through the case & HDD cage to destroy data on a physical HDD, you have bigger problems.
Very best,