SUMMARY: My chief philosophizing here is that the mind has a jukebox; it relates music as memories; and indeed, links new events to existing musical memory devices.

Who cannot attest to the songs that are stored in a person's mind? These are learned with the passing of time as we move through gestation, birth, schooling and into adulthood years. We build up, each of us, a collection of songs we've heard. We hear tunes and songs on radio, television, live concert, from ordinary people whistling/singing, in music class, in retail and work shops, through home speakers, portable playing device and myriad other places. Music is so ubiquitous too, during a lifetime.
The mind stores it all, even songs we like less, as much as those we enjoy more.
Hazard not to say that songs heard more often, are reinforced in the mind, better understood, with lyrics or tune elements better recalled.

Evidently, the human mind has a "jukebox." A song or tune can come back into mind because we hear it again in our immediate environment, that is, an "active or environmental recollection of music."
Another kind of recollection though, is when the mind has no external stimulus to trigger the remembering of a song or tune. The mind simply thinks of it, like an echoing memory or for personal pleasure. This could be called a "random or self-stimulated recollection of music."

On this self-stimulated kind, an interesting point can be noted, or hypothesized: that somehow there is still some kind of less direct trigger for thinking of a song. Perhaps we heard a song recently and so it keeps playing again in the mind. If this is not the case, if a song/tune was not heard for a long period of time, then perhaps some cues in the environment such as hearing a word/phrase or group of beats/noises, help us to again recall a piece of music.
This refers to the use of logical processes from the standard senses--mostly vision and hearing--to give an input that links to brain memories of music pieces.
Besides the logical though, there is another path to recalling a song, without recourse to hearing it directly in the outside world, and without happening to hear a phrase or set of musical beats. The other way is not through the five senses, but rather through the emotional consciousness.
Music always relates to a feeling or feelings. If a feeling is triggered within the human, then all the more possible is it for the person to mentally recall a song or tune, that matches.
Why? To what purpose? The human mind finds it engaging and useful to link events, building on what it already knows and has memorized/stored.
Yet also, to have a tune that matches a feeling of the moment, can be a sympathetic play, like an offering, but also help the brain, in some logical way, to store memories of a current mood/emotion in the mind. All events/feelings are stored by the mind as best it can; the more something happens or repeats, the more easily it is stored permanently and strongly in mind.
The mind uses relations of things to create or fuse together memories.

Why use music? Why recall it in a moment? Or more the question could be reversed, as to why not.