Actually, it can also be a warning about a road hazard ahead, or a police speed trap. I had a guy flash his headlights at me during the day last week, and it was to signal me to turn around because the road was blocked ahead.
Nice gesture, except I had no idea which of several messages he might be sending me. I certainly wasn't going to reverse direction at that point, seeing no problem at the moment. So I drove on, until road signs gave me ample warning, and I did have to stop and turn around.
But if someone flashes their headlights at me at night, I will check mine. And I'll flash at others, but they rarely get the message and keep driving with their lights off.
BTW, as Military Police directing traffic in the US Army, we sometimes had to signal to the drivers of tactical vehicles, like tanks, to turn on their headlights as a standard safety precaution when operating on public roads. And we'd point to their headlights with one arm, and gesture to our eyes with our other hand, since the engine & track noise usually made verbal commands impossible. And interestingly that was always understood, despite some of the drivers being novices, and to my knowledge that gesture wasn't taught in tactical driver courses at the time.