In practice that's often not how that works, though.
I had a company I have shares in that split in two and they gave me a choice, either convert my shares to the new company or keep them in the existing company. I didn't automatically get shares in the new company and if I opted too I would have lost the shares in the original company.
What company was this? I have literally never heard of a spin off that did not result in a stockholder getting ownership of the parent and spin off, or the stockholder retaining ownership of one company and being paid out for the value of their ownership in the other company.
Edit: usually (always?) the exchange is preceded by a partial IPO (or a stake in a quoted company exists for some reason) and they are distributing the remaining shares.
I had a company I have shares in that split in two and they gave me a choice, either convert my shares to the new company or keep them in the existing company. I didn't automatically get shares in the new company and if I opted too I would have lost the shares in the original company.