How does food get contaminated by gastroenteritis viruses?

Poor sanitation. Many gastrointestinal viruses are transmitted via the fecal-oral route, so poor sanitation and/or poor food handling techniques can lead to contamination of foods (such as a cook having viruses on his hands after leaving the restroom). Also, the viruses are transmitted on door handles, furniture, keyboards, elevator buttons, phones, stair railings; and by shaking hands, changing diapers, etc...
Airborne or touch. Most food gets contaminated by people not washing their hands and transferring the infection they have on their hands to the food. If food is not cooked properly, the virus goes thru your GI tract. If someone has a cold and sneezed near your food, you can also pass virus particles through the air. That is why people should cover their mouths when they cough.