I think some items, such as items that have been manufactured by someone might have different IDs that are more like a unique ID for that exact item as it is stored on the server, i.e., it could be a weapon with 2 sockets, a blemished garnet and a diamond of dragon in it, +7, manufactured by dumbfck, with max vit but not max mag.... or something... It would be impossible to have all possible combinations for these sort of things, so I would guess once it's made, it is given a new unique ID as it is added to the server database - Just a hunch.
As for the IDs in world chat... I need to investigate more thoroughly, but I think rather than contain the ID for the item as you might see in your inventory, I think it's more of an ID to identify that item within the item link function. Say for example, you scroll up the chat, there might be 50 different linked items, each of which will need to be unique. As far as I remember, if you link the same item twice in chat, it will have a different ID the next time, although I can't remember for certain if this is the case. I'll check if I can find some time to play with this again.
If anyone else can figure out how this hangs together, I'd be most grateful too :]