You thought you were protected because you installed an antivirus software but still got infected with a virus and/or unwanted programs. There are a few reasons for this issue.
First, most all anti-virus software products are reactive and NOT proactive. In most situations you will get a virus or unwanted program first, and then you hope the anti-virus product will detect and remove it. The key word is "hope".
Potentially unwanted programs are similar to a virus but are not considered the same. To you and I they are just as much a pain in the butt as a virus. Unwanted programs can wreck havoc on your computer and don't appear to be any different than a virus. However, your anti-virus software might not feel the same way. Because of the "potentially" unwanted program classification of some software, anti-virus software may not detect it or remove it.
Some unwanted programs have started using licenses agreements and acting very much like legitimate programs. Anti-virus programs will typically ignore these type programs altogether.