They all were created by a person with the explicit intent of being a virus. Therefore, viruses are not created by accident. They can, however, be contracted and passed along by accident. In fact it may be weeks until a person even is aware that their computer has a virus. All viruses try to spread themselves in some way.
Some viruses simply copy clones of themselves all over the hard drive.
These are referred to as cloning viruses. They can be very destructive and spread fast and easily throughout the computer system. To illustrate the way a standard cloning virus would adapt to its surroundings a theoretical example will be used. Macintosh's Netscape to download some material on photosynthesis. Included in that material is a movie file which illustrates the process.