Here, smoking is the confounder.
The exposure is coffee drinking and the outcome is heart attack.
To be a confounder the variable has to be a cause, or a proxy for a cause of both the exposure and the outcome. It does not have to be a direct cause.
So here, it is sufficient for there to simply be correlation between coffee drinking and smoking, because they share a common cause.
One of the best way to understand confounding, and causal inference in general is to use Directed Acyclic Graphs (somtimes called Causal diagrams). See work by Judea Perl on causality for details of the underlying theory. To illustrate, consider the following DAG:
This was produced with DAGgity (www.dagitty.net), a free online too which implements DAG theory with a view to explaining confounding and to inform the minimal set of covariates to adjust for in a regression model to obtain the true causal effect. You may want to click on the figure to get a more detailed view. Here E is the exposure and D is the outcome. A is a cause of both E and D, so is obviously A is a confounder, and DAGgity tells us in the top right hand corner that if we adjust for A in a regression model we can obtain the true total causal effect of E on D. It is important to understand that this is the case only is the DAG is "correct" (ie we have included all relevant variables and the directions of causality.
Now, note that in the top left corner it says that variable A is "adjusted" - that means we have observed it. However, in the particular example in your question, we haven't observed it (we may have no idea what it is, only that it exists), instead, we have observed S (smoking) and now we have the following DAG:
So, there is no causal relationship between smoking (S) and our exposure (E), but they will be correlated due them having a common cause (A). Note that in the top left corner we have specified A as unobserved, and in the top right corner DAGgity tells us that we simply need to adjust for S (smoking). So coffee drinking isn't a "true" confounder, it is a proxy for A, which is the true (unobserved) confounder, and that is probably at the heart of the confusion here.
Now, let's introduce another, unobserved, confounder, B:
DAGgity now tells us that we cannot estimate the true causal effect, and that is because we have residual (confounding) due to the unobserved confounder B. Sadly, this is often the case in observational studies, which is why clinical trials are considered the gold standard in terms of causality (this is not to say that trials are always perfect.). This also explains why it is sometimes said that correlation is "poor definition" of a confounder: the correlation between smoking and coffee drinking is not solely due to A, it is distorted by B.
To sum up, the issue has to do with "true" confounders, and "proxy" confounders, and whatever assumptions are made (or not made !) about unobserved variables and the causal relationships.