Why do pop up ads automatically download .exe files?


So I was using a movie streaming website, (the ones with all the pop up ads at each click). Usually I just close the ad and nothing happens but recently when the ad pops up a .exe file is downloaded and luckily chrome stopped it as it was labelled dangerous. I’m just curious as to how a file is automatically downloaded without my permission and what I can do to prevent it?