How will shazam download the music to my phone

Solution
Have you checked here for how Shazam works?

https://www.shazam.com/

https://en.wikipedia.org/wiki/Shazam_(service)

If so, what questions do you have?