Some medicines are easier on the stomach when there is food present, which lowers the chance of nausea or stomach upset. Others are absorbed better, or only properly, when taken with food. The instruction is there for a reason specific to that medicine.
Taking with food generally means having the medicine around the time of a meal, often during or right after eating. A small snack is sometimes enough, but for medicines that need food for absorption, a proper meal may matter more. By contrast, some medicines say to take on an empty stomach because food reduces how well they work.
If the timing is unclear, or if you find a medicine upsets your stomach despite eating, check the leaflet or ask your pharmacist. They can tell you exactly how food affects your particular medicine.