The rules of the protocol and the cryptography used for Bitcoin are still working years after its inception, which is a good indication that the concept is well designed. However, security flaws have been found and were fixed over time in various software implementations. Like any other form of software, the security of Bitcoin software depends on the speed with which problems are found and fixed. When issues are discovered, and fixed as a result, Bitcoin continues to mature.
Thefts and security breaches that happen on diverse exchanges and businesses are often misunderstood and misconceptions are common. Although such events are extremely unfortunate, none of them actually involve Bitcoin itself being hacked, nor imply inherent flaws in Bitcoin protocol; just as a bank robbery does not mean that the dollar has been compromised.  Following the last hack job in 2016, it was just another day in the market for bitcoin traders and, while the currency plunged at the time, those losses have been recovered since with bitcoin rising steadily.
If you keep your bitcoin on an exchange or wallet provider online, there is always a risk of attack. If your local wallet is used, the situation is much safer; but you must pay careful attention that the private keys of your wallet are not exposed – that is how bitcoins are stolen.  Hacking bitcoin is too difficult and hard; what hackers typically do is put a “trojan” in junk mail which a user opens, and when opened all the info about their wallet is stolen so funds can be transferred, usually to multiple accounts in order to avoid being tracked.  This is common and can be easily avoided by simply not keeping a large amount of bitcoin in one account – and certainly not opening junk email, or clicking links in email from senders unknown to you.