They are both spread the way many common viruses are spread, especially those affecting the upper respiratory system like colds and flu. For specifics:
Spread of the common cold:
You are most likely to get a cold if someone sneezes or coughs over you or near you. To avoid the spread this way, you need to stay at least a 6 foot diameter distance from the person. Cold viruses are in the air on respiratory droplets for a short time after a cough or sneeze. Although they can travel in the air for only a matter of seconds and for only about a six foot diameter around the person who coughed or sneezed before they drop out of the air onto surrounding surfaces, that is still one of the most common ways to catch a cold. So, being in a crowded public area where you can not stay at least six feet away from others is one of the most likely ways to catch a cold, besides direct contact with the person who has a cold (shaking hands, touching their skin, sharing eating utensils or kissing) or contact with things they have just contaminated.
You can also catch a cold from someone else by touching their mucous membranes or picking up respiratory droplets on your hands that have been ejected with a cough or sneeze and then touching your own nose, eyes or mouth, even hours later. Keep your hands washed frequently and avoid touching your face, especially the mucous membranes of the eyes, nose and mouth, and you will likely stay cold-free.
You can also pick up viruses by touching somewhere a sneeze or cough has touched, e.g., a sick person's hands or used tissues or a nearby counter top or phone. Colds are spread when the viruses enter the body through mucous membranes, typically of the eyes, nose, and mouth. Any transfer of body fluids between an infected person and a healthy person (e.g. a sneeze, a kiss, a shared beverage) can spread a cold. Also, a person with a cold can contaminate a surface such as a table, phone or doorknob with her hands. If a healthy person touches that contaminated doorknob and then rubs her eyes or nose or eats with her hands, she can get the cold. For this reason, regular and thorough hand washing is recommended especially during cold and flu seasons, see the related question below on how to properly wash your hands to remove germs.
You can spread a cold by going to school or work or out in public when sick. It is best to stay home and rest to get well, rather than take the virus in public and make others sick, too.
Spread of the flu:
It goes from person to person through close contact and direct touch, indirect touch, or respiratory droplets in the air carrying the virus short distances from person to person or from person to environmental surfaces through coughs and sneezes. If you touch where a person with flu touches, you will most likely pick up the virus and get the flu, too. That is how it spreads indirectly. Stay a minimum of six feet away from someone with a known infection and avoid close contact from being in crowded places.
You get direct spreading when you have skin to skin contact or direct person to person contact with an infected individual, such as shaking hands, kissing, or caring for a child or other infected person with hands-on care. You could be infected by getting too close to someone who has it. Do not hug people who have the flu. Wait for them to recover, then hug them (a lot).
Do not share drinking glasses or eating utensils with someone, this can also spread the disease. There is some evidence to suggest that it can be spread through gastrointestinal means, such as saliva, emesis (vomit), and feces (stool).
The importance of hand washing before and after eating, using the restroom, or providing personal care to an infected individual can not be over stressed. Avoid putting your hands in your mouth and nose or rubbing your eyes before washing your hands. Teach your family proper hand washing technique. (See related question for this information).
Flu viruses enter the body through the mucous membranes - the eyes, the nose or the mouth. They go from person to person through close contact and direct touch, indirect touch, or respiratory droplets containing the virus being ejected through coughs and sneezes from person to person or from person to environmental surfaces.
If you touch where a person with flu touches, you will most likely pick up the virus and get the flu. That is how it spreads indirectly. Stay a minimum of six feet away from someone with a known infection, avoid close contact from crowded places. The six foot guideline is based on how far respiratory droplets can go before falling to the floor or other surfaces. They do not actually float in the air to be an airborne pathogen. The respiratory droplets that carry the virus particles come from a sneeze or cough of an infected person.
Flu viruses can also be spread by handling money soon after an infected person touched it.
Flu is not spread through swimming in chlorinated pools, or by being in the water at recreational water parks that regularly treat the water. It is not spread in fountains that use purified water or in spas. There is some risk of catching it at beaches, or at recreational water theme parks from people among the crowds and not in the treated water, just as in any other crowded public place.
Protect yourself and others by getting your flu vaccination, it is the most important and most effective way to stay well and to avoid spreading the flu to your family, coworkers, and in public. Flu vaccines, as currently made, have been proven to be safe and effective over decades of use.
Another very important method of prevention is proper and frequent hand washing and regular hygiene. To help prevent the flu, wash your hands frequently with soap and warm water, and avoid touching your face, eyes, nose, and mouth. When you have the virus on your hands and touch the tissues in those places, that is how the virus enters your body.
How Long Can You Spread It When Infected?
There are still studies in progress to determine the best answer to this question. A commonly accepted guideline stipulates that one should be suspected to be capable of still spreading the flu until 24 hours after the fever subsides [while taking no fever reducers]. This is the guideline suggested by the CDC and WHO.
Testing of swine flu in one study using a very sensitive test to detect virus in the nose or throat found that 80 percent had it five days after symptoms began, and 40 percent seven days after. Some still harbored virus as long as 16 days later. How soon they started on antiviral medicines such as Tamiflu made a difference in how much virus was found, but not whether virus was present at all. For best results Tamiflu and other antiviral medicines should be started within 40 hours of the first symptoms, according to the most recent findings.
Doctors know that people can spread ordinary seasonal flu for a couple of days before and after symptoms start by studying viruses that patients shed in mucus. The first such studies of swine flu imply a longer contagious period.