In DnDBeyond, there is a passage explaining how the music and magic connects:
In the worlds of D&D, words and music are not just vibrations of air, but vocalizations with power all their own. The bard is a master of song, speech, and the magic they contain. Bards say that the multiverse was spoken into existence, that the words of the gods gave it shape, and that echoes of these primordial Words of Creation still resound throughout the cosmos. The music of bards is an attempt to snatch and harness those echoes, subtly woven into their spells and powers.
Bards are those who can discover the magic hidden in music. Even not all performers can be called a bard:
True bards are not common in the world. Not every minstrel singing in a tavern or jester cavorting in a royal court is a bard. Discovering the magic hidden in music requires hard study and some measure of natural talent that most troubadours and jongleurs lack. It can be hard to spot the difference between these performers and true bards, though. [...] But a depth of knowledge, a level of musical skill, and a touch of magic set bards apart from their fellows.
The next section Creating a Bard gives some examples on how you become a bard, that is how you acquire the knowledge, musical skill, and magic.
Some bards acquire their magical music through extraordinary means, including the inspiration of fey or other supernatural creatures.
Did you serve an apprenticeship, studying under a master, following the more experienced bard until you were ready to strike out on your own?
Or did you attend a college where you studied bardic lore and practiced your musical magic?
Perhaps you were a young runaway or orphan, befriended by a wandering bard who became your mentor
Or you might have been a spoiled noble child tutored by a master.
Perhaps you stumbled into the clutches of a hag, making a bargain for a musical gift in addition to your life and freedom, but at what cost?
You can of course craft your own story, after all you're a bard! But first, you must understand how to use hidden magic in music. How? You tell how! You decide how you acquire: the knowledge, musical skill, and magic. The guidance suggest a more traditional approach: you learn it from someone who is/was a bard, or you realize there is magic within music because of your encounter with supernatural beings.