Most headaches are related to stress
Most of the headaches you currently suffer from, and have had throughout your life may be “tension headaches” these are usually associated to your mental health.
If you are often thinking about past or recent stressful experiences it starts to generate that stress in your head which then manifests as pain, notice that this pain could also manifest in different parts of your body and not always in the head.
This is why “distracting your mind” by going for a walk outside in nature works, other things you can do is getting a massage, engaging in an activity that changes your though patterns such as painting, crafts, playing some kind of sport, or doing another form of exercise.
It is mostly the mental switching that goes along with these activities that makes your headache fade away, because you detach from the stress you have previously generated from stressful thinking.