Washing your hands bathroom is good but once touch the door handle and lightswitch those germs might be back. Others might not do so well at the handwashing.
Correct hand washing, which means running water and soap and scrubbing will definitely help in lowering the chances dramatically of getting food poisoning, but ultimately if the food is tainted/spoiled and
salmonella is present you will get food poisoning. Hand washing alone cannot prevent it but it certainly should be part of a stringent hygiene routine every single day.
Food poisoning comes from eating food that has gone bad or has been poisoned in some way. Washing your hands will prevent illness from salmonella or e coli. These poisonings occur when you handle raw meat and then do not wash your hands after handling the meat before touching something else.
Washing your hands period before you eat can prevent the spread of bacteria onto the food you're preparing and therefore should always be done before cooking/eating.
It can prevent it to an extent, but it's more likely to prevent you from contaminating food that you serve to others than prevent you from getting sick. The best way to avoid food poisoning is to eat foods that are fully cooked, well-washed, and not cross-contaminated with other foods.