Does "within an hour" mean before, after, or both?
Solution 1:
Within is a single word. In the sense of your example, it means something like during, or before the end of:
do not drink or eat during the hour before or the hour after you take these pills.
Consider also:
I want to have been promoted within a year of joining the company.
I want to live within five miles of the office.
Within the boundary of my lands, I am king.
See definition on Merriam-Webster.
Edited to point out that it applies to the hour before as well as the hour after. The other answer is better.
Solution 2:
do not drink or eat with in an hour of these pills
'Within' means inside some sort of time frame... so this sentence literally means that you must wait until an hour after eating before taking the pills, and must not eat until an hour after taking the pills.
In my experience, this is very usual advice - I don't think it was intended this way; it could mean you need to wait for an hour after eating before taking the pills, or it could mean that you have to wait for an hour after taking the pill to eat.
I would interpret it as the latter, but it isn't entirely clear.