Many people are surprised to learn that computers can be infected by malware when you first buy them. Just because you are buying a new computer from a trusted vendor doesn’t mean that your machine is completely safe from viruses.
Computers can have malware installed before you receive them in a variety of different ways, and for a variety of different purposes. Often this is done if malicious entities are able to get access to the computers while they are being manufactured. A worker might be paid substantial sums of money if they are able to infect the computers being produced at their location. In this way, a single corrupt worker might be able to infect thousands of machines in a short period of time. Then when you buy a machine, whoever controls the malware has access to whatever you do on it.
Additionally, these attacks can be more sophisticated and calculated than what could be perpetrated by a single rogue worker. There have been some cases where governments have infiltrated computer and component assembly facilities, and have managed to embed incredibly sophisticated programs deep within the machine. This is done for a variety of reasons. For example, if a government knows that a batch of computers is likely to be shipped to a foreign nation of interest, they could embed malware deep within the machine, using clever tricks in an attempt to prevent the malware from being erased or noticed when the purchasing companies receive the machines and ready them for distribution. In these cases, there is not much that you can do except be aware of the potential that your machine could be compromised. If you are holding sensitive data, it might be worth your time to consult an expert who can come and completely clear a machine of any potential infection, as well as advising you on how to secure your valuable data.
Finally, some companies preload things such as adware and bloatware on their machines before shipping them. These programs are designed mostly to either serve you advertisements (making the company money), or are programs the computer vendor was paid to have installed. Either way, removing these programs will help your computer run more smoothly, as well as removing potential avenues for infection. Unwanted and intrusive programs, and advertisements are both vectors by which other malware can gain a foothold on your machine, potentially infecting you and stealing your data.