Terms change id after importing

Off the top of my head, you’d have to either:

(a) bypass the import functionality in WP and do it direct to the database, so the term IDs stay the same (i.e. export/import from phpMySQL).

or

(b) write a “run once” data migration function to update your term IDs once they’re imported, using a reference table.

or

(c) change your plugin/widget to detect the term slug or name instead of the ID.

I believe the last of those would be “best practice”, as it ensures your plugin works regardless of the data in the back end. Using the visible/accessible parts of the data is always better, even if it’s harder, longer and/or stupidly difficult with WP’s available functions!