The mechanism for this is that when your eyes or ears are exposed to a particular frequency of pulses or beats, the thalamus first distributes this information to the entire brain, including the visual and cerebral cortex where neural activity begins to synchronize to the incoming frequency, producing hemispheric synchronization and a balance of brainwave activity across the brain.

You may recognize the "binaural recording" from ASMR, where the technique is often used. This explains why, if you search for "binaural" on YouTube, you get a mixture of two entirely different kinds of results: binaural beats and binaural ASMR recordings. It gets especially confusing in that there's some questionable and/or unexplored science surrounding each one.
Some research suggests that the benefits from brainwave entrainment can last a lot longer, and still be seen for some time after you've stopped using it.  Study participants have still maintained improved test scores a few weeks after the stimulation had ceased.  Research on the long-term benefits has so far been minimal though, so how long the effects last is still up for debate.
The activity of neurons generate electric currents; and the synchronous action of neural ensembles in the cerebral cortex, comprising large numbers of neurons, produce macroscopic oscillations. These phenomena can be monitored and graphically documented by an electroencephalogram (EEG). The electroencephalographic representations of those oscillations are typically denoted by the term 'brainwaves' in common parlance.[4][5]
×