Websites get hacked when the security measures are not taken seriously for the website. For example, using outdated files or applications, etc.