Correlation does equal causation, both statements are true. Just missing some conditions there. Say you repeatedly hit your head with a hammer, it would be right to correlate it with the pain in your head. But if your were walking, saw a shooting star and felt a pain in your left knee, no that does mean the shooting star caused it.
"Repeatedly" is the key word there. A one-time incident with a shooting star and a pain in your left knee doesn't give much of a "correlation"; you need a few more data points for that.
And a more precise version of what should be meant by "correlation is not causation" is "if A and B are correlated, that, by itself, is insufficient to suggest that A causes B, given that the same correlation would show up if B caused A or if C caused both A and B". The "conditions" in your first example are what let you conclude that "A causes B" is the most likely case.
(If somebody were able to make their headache go away by hitting themselves on the head with a hammer, that might be a case of "B causes A" there, but that would be a case of the pain coming first and the hitting-yourself-on-the-head coming later; if somebody were to have a neurological disorder that 1) caused pain in the head and 2) caused an impulse to hit himself or herself on the head with a hammer, that would be a case of "C causes A and B", but, in that case, the pain would probably happen before he or she hit himself or herself on the head.)