From the Merck website :
Drug absorption is the movement of a drug into the bloodstream after administration.
Absorption affects bioavailability—how quickly and how much of a drug reaches its >intended target (site) of action. Factors that affect absorption (and therefore >bioavailability) include
1.The way a drug product is designed and manufactured
2.Its physical and chemical properties
3.Other ingredients it contains
4.The physiologic characteristics of the person taking the drug
5.How the drug is stored
If a tablet releases the drug too quickly, the blood level of the drug may become too high, causing an excessive response. If the tablet does not release the drug quickly enough, much of the drug may be eliminated in the feces without being absorbed, and blood levels may be too low. Drug manufacturers formulate the tablet to release the drug at the desired speed.
Essentially, most drug's absorption rates are slowed down by food in the digestive tract, which is beneficial for various reasons depending on the drug.
Some pills are irritants to the stomach, in which case they usually have a coating that may need an acidic environment to break down. Food would assist in this, as well as serving as a sort of diluting agent and even a physical barrier for the stomach.
Conversely, some nutrients (and certain pharmaceuticals) are absorbed by the stomach lining and small intestine much more efficiently when the body is actively digesting food, which is why vitamins and other supplements have the food recommendation.
I think that 'before or after' food should be read as 'shortly before or after', i.e., so food and pill are digested simultaneously. Otherwise, I believe they just don't mention it. Of course, this is a simplistic rendering of pharmacological absorption vis a vis food (there are some very specific interactions; grapefruit and various blood pressure medications come to mind), but this is the general answer to your general question, I believe.