Viruses are computer programmes that spread from one computer to another by themselves and either cause harm on the infected computers (destroying files, taking control of the computer etc.) or collect information from the computer (send files forward, pry passwords etc.).
You can mainly avoid viruses with the use of common sense. Do not open files that have come from unknown sources and avoid going on suspicious websites. If you encounter enquiries that ask for something to be installed on the computer while browsing the internet, you should categorically answer them in the negative. In addition, you can use antivirus software which detect and delete viruses from the computer.