I have been playing around with Joplin for a day now and unfortunately I don't think I understand at all what it does (so I cannot really make it my note-taking app).
The latest example is syncing against a local webdav-directory: I have one note (only 1!) with one attachment in joplin - yet the sync produces 12 md files in the sync-target - while the attachment does not seem to be synced at all...
In the resources-directory I have 3 pngs that have nothing at all to do with the one note I currently have and they still have entries in the resources-table for god knows what reason...
I currently do not trust the sync-functionality at all, my impression is that with the complexity you currently have accumulated you are bound to run into problems eventually.
I really would like to use Joplin as the functionality is great, but a reliable sync is very important and unfortunately I see many issues that people have with syncing...
Probably this is all my fault not understanding properly what the intended behaviour is, is there any documentation on how all fits together?
I've been using Joplin Cloud to sync, and I haven't had any issues -- well, except one trivial one: When I insert a graphic in a Joplin note from my iPad mini, the graphic tends to later also appear in a note by itself -- in addition to the graphic where it should be. I simply delete the extra. That's the worst synching issue I've faced. Oh, perhaps I should mention that I'm running Joplin on my MacBook Pro (both desktop and CLI versions), iPad Pro, iPad Mini, and iPhone. They all sync up beautifully.
I've never had any sync issue using nextcloud myself.
The multiple files are because Joplin doesn't just sync your plain notes, it syncs note revisions and changes to notes. So I suspect you are syncing revisions as those extra .md files. This also includes deleted files which only get removed once your note revision period has run out.
Is the attachment definitely in Joplin and not just a local reference? i.e. it got a Joplin generated id as the filename?
I don't know if the two of us are talking about the same issue, but the problem of doubled-up notes I was constantly encountering with the previous iOS version has luckily been resolved in the latest version on the App Store (V. 12.10.5). All new notes generated from pictures (or any other data) via the iOS share sheet were affected, but that's resolved now.
I'm not able to truly answer your questions, but can provide some information:
I've got 3500 notes, using 4200 resources, 159 folders.
I sync an android phone, a tablet and a Windows computer.
I used Dropbox for syncing perfectly without a problem for over a year. Then, mostly to support Joplin switched to Joplin Cloud for a couple years. I've never had any issue.
Another likely explanation is that you're getting multiple notes because "Note History" is enabled (Note History | Joplin) and new copies are being generated to facilitate returning to previous version(s) of the note.
I personally like this feature, but if you don't want it you can turn it off in Preferences/Note History.