There are many ways viruses can infect your device. Most commonly, malware can infect you through user-based actions such as downloading and installing cracked or pirated files, browsing infected websites, opening email attachments, and so on.
Even if you think you can avoid these things, it’s always better to be safe than sorry. Get an antivirus!