The title pretty much explains it. You're listening back and forth between a commercial industry standard reference song and the song mix you're mastering, comparing sonic qualities between the two. How does the song you're mastering differ from the commercial reference song?
As you master a song, your goal is for it to sound more and more like the industry standard reference song in every sonic area. You continue listening back and forth, while adding effects until you come as close as possible to replicating it. I say as close as possible because if a the mix you're working on is very poor, you won't be able to replicate it.
A/B comparison is "trial and error testing against the reference track." That's what you're doing in effort to match it.
It's funny how this works, but after you do this a while, the industry standard reference track is in your head! You know exactly where each sonic quality is supposed to be and how to quickly apply the effects needed to get your master there. When you reach this point, this is when you can master songs a lot faster.