I cannot change icon on the components

selecting ‘detach instance’ is working but dragging the new icon on the existing one is not working.

When you detach an instance, it is no longer an instance.
Instance swapping only works on instances.
Also, just in case you forgot to mention it, to swap instances you need to hold down alt/opt.