Vanyel, I was about to say something similar, although it's only a theory.
A particular credit grantor(ccc, mortgage co., car dealership, etc), when requesting CR's from a CRA, is assigned a particular code for that particular industry, for that particular CRA. And all inq's contain that specific industry code. Kind of like a SIC. So it's universally recognized. And it attaches to an individual's SSN. That's how it knows.
Just a theory(I'm full of them, just many are totally off base. lol)