I'm relatively new to cryptocurrency so I have a limited understanding how it all works. That being said, I think I get what happened. Exchanges are kind of like banks. Its a place where people keep their bitcoins. This also means that someone, other than yourself, is holding your bitcoins. The exchanges got hacked, and the mechanism that "stored" everyones coins got compromised.
While there is no fool-proof way to secure your bitcoin, I am a huge fan of using multiple paper wallets for storing larger quantities of bitcoin, and keeping a smaller amount of usable currency in digital wallets. Don't loose faith in bitcoin. All it is, is a decentralized digital bank account. Keep in mind that it is digital though. Any time you give your money or account numbers to a third party, there is risk.
RE: How can Bitcoins be stolen?