Here's one way that a sync system could support signing in-to and out-of different server-side sync accouts.
I'm going to consider every note on every device to be unique, initially, since the only way to have duplicate notes would be to have manually copied them between devices.
Since each local note is unique at this point, signing in to a sync account for the first time just adds all of the local notes to that sync account, and records the unique id assigned by the server (keeping the local unique id as well). The sync account "owns" these notes now, and they will appear on any device that signs in to that account.
Other notes from the sync account are downloaded to the device. Each of these gets a local unique id, just like it had been created on the device (and it keeps the server-assigned id).