How do companies pre-program chips?
They make ZIF (zero-insertion-force) sockets for basically every package available. 

Such as QFN:


Or SSOP:


And yes, they do make ZIF sockets for BGA devices.



And programmers that support many sockets at once:



Or for really large volumes, completely automated programmers with an integrated robot:



It's not hard to imagine how something like that could be adapted to a production-line robotic system, particularly when most modern MCUs don't actually need that many pins to be connected to be programmed.

Just google Production Programmer, and have a look around. 



Disclosure: All the links here I just found via google. I have no actual experience with any of these companies.