A disease is contagious if it can be transmitted directly from person to person. Genetic diseases, for example, are not contagious. Neither are many diseases caused by environmental exposure, such as radiation sickness. Even other diseases caused by parasites, bacteria and even viruses are not contagious and can only be contracted through a vector or a contaminated source. However, all contagious diseases are passed either by a bacteria or virus or, more rarely, a parasite. This understanding of the nature of agents of contagion is often referred to as "germ theory" and dates back to the work of Robert Koch in the 19th century.
In addition, the level of contagion often varies widely from disease to disease, even within the same group of diseases. For example, both the common cold and herpes are caused by a virus passed by contact, but a cold is more contagious as the cold virus is very hardy and remains virulent even outside the human body.
Even what is essentially the same disease can have different forms with different levels of contagion. Bubonic plague is not terribly contagious and usually must be passed by infected insects, such as fleas. However, it can quickly turn to pneumonic plague, a bacteria that can be transmitted through the air and is much more contagious.
Just because a diseases is very contagious doesn't mean it is very virulent. For example, tuberculosis is very contagious - being in the same room with a person with active TB will expose you to the bacteria. However, most people exposed to TB will not develop the disease.
Contagious diseases can often be very difficult to get infected with. For example, HIV is contagious, but usually requires direct body fluid to blood transmission in order for a person to get infected.
Whether or not a disease is contagious is often vital in establishing a diagnosis. For example, in Euphoria (Part 1) and Euphoria (Part 2), the nature of Eric Foreman's illness was discussed within the context of not only whether it was contagious, but how it was transmitted.