This bug exists because the SE system supports two styles of links. There is the "inline" or "direct" style of link:
But in addition, there is the "indirect" link, where the URLs are placed in a separate place, usually at the bottom of the post:
The problem is that the link and image insertion tools built into the editor insist on using the latter form, which requires the assignment of arbitrary numbers to provide the association between the two parts of the link. The "convert to edit" feature fails to account for the collisions between the numbers used in the two posts being merged.
My point is that if the post editor used the first link format instead of the second to begin with, this would become a non-issue with no further work required.