When flashing lights give a person a headache it usually means that the person is more sensitive to flashing lights than other people.
Flashing lights and strobe lights operate at a frequency of between 1 Hz to 20 Hz which is also approximately the frequency of human brainwaves.
So that's one reason that the flashing lights give people headaches.
People who also have seizures can have the seizures triggered by watching flashing lights or other flashing things such as on a game or TV or computer screen.
So if you have seizures such as epilepsy then you should avoid looking at flashing lights or watching TV with flashing lights or anything that constantly flashes or flickers.