The term "Botnet" refers to any collection of computers that run certain software putting them under the centralized control of the "bot master". While not always malicious, the term is mostly associated with networks setup for malicious purposes by hackers and criminal organizations and used for illegal purposes.
Malicious botnets are comprised of many compromised computers. The computers can become infected with malware through many well known methods such as web browser vulnerabilities, buffer overflow flaws in popular software that can be exploited, operating system security weaknesses or just naive use by the owner (such as downloading and running e-mail attachments from an unknown / untrusted source).
Botnets are often controlled from IRC channels and an infected computer might automatically connect to an IRC server for instructions. While a certain botnet might use the same malware, that does not mean that a single form of malware is used with only one botnet. Some tools are often used by under-experienced hackers to scan networks for vulnerable machines and then exploit the weakness.
An infected machine might also be able to grow the botnet itself by scanning its own network, or addresses on the Internet for any weaknesses that it can exploit. In recent years, malware has been more associated with social networking so it is unsurprising that botnets have found a way to grow quickly in these times.
Botnets can be used for anything from spam to fraud, or just to carry out denial of service attacks on Internet targets for any variety of reasons.