I use Sigil for this, it has a couple of specific tools that help -- Insert->ID and Insert->Link.
Can't see anything similar in the calibre editor (surprisingly)… maybe I missed it.
The Sigil manual should provide you with sufficient detail to fix what you have using the calibre book editor -
Sigil User Guide - look for the
Links and IDs section in the ToC.
BR