It seems to me that Shazam turns the microphone on as soon as the app in launched on iOS.
Yesterday I wanted to Shazam the second song of an Instagram video playing on my computer. The app was open while the first song was playing and I pressed the record button as soon as the second one started playing. I was really surprised to notice that the song found by Shazam was the first one and not the second.