An excellent question!
For most purposes, the frequency of a photon is just a relative measure of various useful qualities, such as the angle at which it is refracted by a particular medium, or how much energy it imparts to an electron in an atom of some material. From this, it’s not clear that frequency – the number of occurrences of some regularly recurring phenomenon in some duration of time, or if an alternative explanation would server as well. For example, might photons associated with higher frequencies and thus higher energy (which is directly proportional to frequency, ie:

where

is energy,

frequency, and

a constant) not have, say, just have proportionally more mass?
When one looks at wave-like behaviors of light, it becomes clear why the frequency of a photon is truly some that could, in principle if not in practice, be counted in much the way one can count the number of water wave crests pass a fixed point, or the movement of the diaphragm of a microphone moved by sound waves.
For example, the interference pattern recorded on a photographic plate or detector array after passing through a
double slit apparatus is identical in all but scale one produced by water waves passing through a similar apparatus.
Interferometry can be used to precisely determine distance to within increments smaller than the wavelength (

, where

is the speed of light) of the light used.
So, while it’s not practically possible to determine the frequency of a photon by a simple counting processes, as we can with water waves or sound waves, we can reproducibly determine it with great precision using indirect methods that can be performed with very simple instruments (a workable spectrometer can be made with paper, tape, and nearly any sharp-edged material, such as is illustrated in
Make Your Own Spectrometer|Orbiting Frog)