Here is my Occum's Razor explanation. Obviously this is a guess, but it's a simple explanation.
They are not building these to order. Basically there are just a bunch of exterior colors and two wheel options. So they are just building a batch of black, then white, then silver, then blue, then red, and then they throw on either 18" or 19" wheels on each car. There is no reason to assume they are not starting the production line in sequential VIN order and by the time the cars reach the paint shop they simply consult inventory to see if they are running low on a particular color and then do a batch of 25 or so cars in a particular color.
Then, once the car clears QA (or at least for major issues that can't be addressed by a delivery center), the car gets added to whatever equivalent of a Google Sheet Tesla uses for inventory.
Now in parallel you have delivery specialists (or whatever title they give--maybe I'm using the wrong term) that are working their way down the order queue. They see that Jane is next and has ordered a red car with 18" wheels and she wants to take delivery in Fremont. The specialist consults the inventory list for a red car with 18" wheels that's in Fremont and once he finds such a car, assigns it to Jane.
Not only that, but if said spreadsheet/list happens to be sorted such that new entries (higher VINs) get added to the top, that would explain why we see some high VINs get assigned and then the gaps filled in as time goes on. And maybe different delivery specialists have different ways of sorting/searching for matching cars so that's why some people are getting higher or lower VINs.
So you say, why can't this all just be done with software?
Well, it can, but said software would have to be written and communicate with an inventory control system, a customer vehicle management system, and whatever other internal delivery systems they have. I suspect at the volumes they are dealing with now, it's not really justified to automate that process at this time when a human (that is likely going to have to get involved anyway) can do the job in about 10 seconds already.