Do not let the same thing happen to you before you know the importance of having a hardware wallet, I have always known that hardware wallet is the safest but I ignored it, thinking I can't afford it, and I could, but I don't want to leave my accumulation of Bitcoin behind and spend hundreds of dollars on a hardware wallet, few open source hardware wallet are not even up to hundreds of dollars.
From what you said about software wallets, I could easily conclude that you were careless with your wallets and that's how you got exposed to hackers. However, It's actually a good thing that you got a hardware wallet but have it at the back of your mind that hardware are not 100% safe. You still have a part to play to ensure the safety of your assets. For instance, If the device you're connected to is infected with a clipboard malware, you could lose your funds when copying an address, so take note. Also, don't create digital footprint of your seed phrase, back it up, keep it offline and somewhere safe.