Q:

How can I get infected by computer viruses?

I would call my self a security aware computers professional, and I was asking my self for a long time now allready. How can it be that male-ware gets onto my computer wihtout me actively playing it or accepting an information about it?
I reinstalled some weeks ago my windows and did the following things in this order(given that all download were done from their official webpage):

installed win7
upgraded it to win10
installed mozilla
downloaded and installed kaspersky (with pre-existing license, if matters for features)
isntalled putty, winscp, tortoise, steam, battle.net and teamspeak, and downloaded software I own on those platforms.
did some ssh stuff between my server and my personal pc to get backups of important projects.
installed flash and adobe and surfed a bit through the web. (watched southpark streams on the german offical southpark site)

especially the last point probably is what caused the trouble, naimingly kaspersky detected 2 days ago 3 trojaners and 2 adwares on my computer.
that page was until some days ago hsoted by comedycentral, but that seemed to have been changed. And it now appears pretty harmfull. My pc is since I watched the streams pretty slow and so on.
But now my actuall question is:
In case I'm right in the assumption that all the previous steps won't have been able to inject harmfull software to my pc, then I'm concluding that there are ways (with java script?!) that are parsed by the browser into creating files on my computer and doing additional changes on my pc making it possible that those files are executed at some point automatically.
But why should browsers implement such features?
And even if they were so important and required, why am I not even informed or asked by my browser about possibly harmfull executes?
I mean for making a just created file beeing at some point automatically executed, there would have to be taken changes on my computer that shouldn't be that common for website applications, or am I wrong and it isn't that common that websites need to acces i.e. my registrys?
So from that point, why does it happen, that js features are supported from a browser that do such config changes on my pc, and why is the rbowser not even asking me about me beeing fine with it?
And for the future, are there other ways to protect against it, except deactivating js?
Or could it be something entirely different?

A:

Drive-by downloads are a real threat. These enable a website to exploit a 0-day vulnerability in your browswer to execute malicious code on your system. Note that sometimes websites are hacked to behave maliciously without the website's owners being malicious.
While browser manufacturers work to fix security problems quickly, the 1534 publicly announced Firefox vulnerabilities are proof that this is a difficult task. Flash is also another well-known source of security problems (currently 1039).
It is also possible that one of your downloads came with malicious files in it. Sites such as CNET are notorious for this. 

