Considering the hateboner Shaw had for Picard, i think Q couldn't have resisted the idea of visiting and playing one of his games with him Maybe that's also how Shaw learnt about what happened in AGT
Shaw: Oh, great, it's Q. Well, what is it this time, going to put me on trial? Offer you powers to one of my crew? Make me role play as Robin Hood? Give me the chance to correct a mistake in my youth? Q: Sorry, snapped my fingers the wrong way. Meant to drop in on a Starfleet Captain that's actually pleasant to be around *Q Vanishes* Shaw: Jackass.
Think we'll never get an official explanation for Shaw knewing about what happened in the Devron system. But at least in my headcanon, Q met Shaw at some point during the decades after BOBW. Can't resist imagining Q messing with Shaw and the possible dialogues
I assume Picard would have made a log about it which would be "required reading at the academy" or something, or at least available to Captains, certainly when you have an unexpected guest commandeer on your ship you might take a few hours to review some of the highlights if nothing else.
I mean, Shaw is so low on the totem pole of things, he most likely served on the Cerritos at some point. Which means he learned absolutely everything from Boimler and Rutherford. He probably fitted right in there.
Shaw was probably Q Junior's first human. "My dad says I get one human friend and I chose you." "Fuck."