We have a nice
tutorial about that topic:
https://gbatemp.net/threads/how-to-...-without-losing-non-legitimate-titles.531950/
Doing this ↑↑↑ should lead to zero data loss.
I have to say I'm tired of repeating this all over and over, again and again:
"Go back to stock and start from scratch!" is the absolute worst thing to do on 3DS (and other consoles). The 3DS is not an Android phone where you can (and maybe must) reinstall the stock ROM after messing up with custom ROMs (which destroys user data nevertheless). The only thing modified on the 3DS is the bootloader. It gets replaced by B9S which loads Luma3DS (the CFW) on each boot. The CFW disables all the restrictions and adds a lot of new features – but that's it. The actual operating system on NAND doesn't get touched in the process and everything works just like on stock systems. Some limitations stay in place – like the unique encryption of SD content.
"Format System Memory" is destructive. By definition. It gives two or three warnings before starting the formatting so nobody says:
"I accidentally formatted my 3DS and now my data is gone!" (still that phrase is omnipresent).
============
If you formatted the target system after System Transfer you should be able to link your NNID (if any) again on the target system and redownload your purchased content. Since formatting the console changes the encryption key the old SD content (I think it gets deleted if it is inside the console while formatting) is worthless even if backed up (the formatting option contains an explanation what it is about to do
before it actually does the destructive work).
Theoretically there might be possibilities to restore the previous KeyY depending on what you backed up before. Might be possible to extract previous saves with old
movable.sed.
Now that the damage is done you can of course start
"fresh" on the target console, use Seedminer, install B9S and all your games not purchased on eShop (like dumped cartridges). For the source console this part of the guide is needed:
https://3ds.hacks.guide/restoring-updating-cfw