What causes headaches in the first place?

Complicated! A headache is defined as a pain in the head or upper neck. It is one of the most common locations of pain in the body and has many causes. 3 major categories of headaches: primary headaches (tension/migraine/cluster); secondary (underlying structural problem) ; cranial neuralgias, facial pain, and other headaches.Finding/investigating the numerous causes of headaches will allow better treatment.
Anything. Headaches can come from fatigue, sleeping too much or too little, eye strain, sleep apnea, snoring, being dehydrated, having chronic sinusitis or allergies, too much caffeine or over the counter headache medication, high blood pressure or something more serious like a tumor. See your doctor and get checked.