This is really more of a psychology question, but there is a substantial philosophical question underlying it which I believe may be the cause of your confusion.
The short answer to your question is just that patterns of waves of air
pressure that we call music stimulate the brain in such a way as to entail the kinds of brain activities that are responsible for generating mental phenomena such as novel thoughts, subtle or powerful emotions, etc. The long answer is more complicated, but in principle can be answered given the proper empirical data about how the brain processes auditory data, what kinds of brain activity are associated with what kinds of thoughts and emotions, how the processing of certain kinds of auditory input functionally entails the kind of brain activity that is associated with certain kinds of thoughts and emotions, etc.
Now, it is a further substantial question to ask how or why it is that brain activity leads to/is associated with consciously experienced thoughts, emotions, and so on in the first place, and this question does indeed have a particular kind of mysterious and seemingly unanswerable air about it (and indeed is still hotly debated by philosophers, who call this 'the hard problem of consciousness'). In this sense, the answer to your question might be considered unknowable or mysterious, but no more so than the question of why I consciously experience
this color when light with a 600nm wavelength strikes my retina, or why I am conscious at all, and so on.
But if we take the existence of consciousness and its correlation with brain activity for granted, there doesn't seem to be anything mysterious or unknowable about the further question of why music has the effect on us that it does. Starting from this point, the proper story about how the brain functions will do the job quite adequately, and empirical techniques can in principle tell us enough about how the brain functions to give us this story.