I would assume that Apple makes that available through some API. With either bogus information for non-existing numbers, or throttling if you look mostly for non-existing numbers. I think the main purpose is that people can’t guess serial numbers of real devices.I feel this will be problematic for sites like EveryMac, where you can search for the product specifications based on serial number.
Now, no one but Apple will have the mapping for what serial number is what product.