The VIN comes fairly late in the assembly line build just in case there's a problem it's much easier to recycle a non-VIN vehicle then one which has been so assigned. So, much later than the paint booth.
But yes, dealerships often advertise vehicles not yet on their lot. Although they're typically good about listing them as "soon arriving" or "in transit."
Note also that they will often list a customer ordered vehicle as well, as after all the dealership owns it until you take delivery, as you might cancel. Also just to create some marketing buzz on a rarer offering such as the GLA45, or any vehicle these days given so relatively few available. So don't be alarmed if you see 'your' vehicle on their website as they won't really sell it out from under you - at least not any reputable dealership.