Shutter speed is simply the time between when the shutter opens until it closes. The camera does not do anything different if the shutter speed is set to 1/30s or 30s, except in some cases apply different noise-reduction since longer shutter-speeds can show more noise.
Modern cameras have a fixed shutter-speed range, typically 1/4000s-30s, but some go both faster and slower, up to 1/32000s until 250s, depending on the model. To get longer shutter-speeds, DSLRs and a number of mirrorless models offer a Bulb mode which lets the user control when the shutter is open and closed, thereby creating longer shutter-speeds. There is still usually a limit though, sometimes in minutes and sometimes in hours, mostly for DSLRs.
Light gets collected during the entire exposure which is why long exposures are taken at night usually. One can do so during the day by using an ND filter which reduces the amount of light that reaches the sensor.
The key as to what appears in the image is to understand exposure. Car lights are much brighter, so they register on the sensor quickly. Car bodies are comparatively darker which is why they look as if they were not there. None of them sent enough light to register on the sensor. Should you have had a slow moving vehicle, it might have registered partially and would appear ghostly.