I think all of these problems come from losing control of a resource due to a war while having deals trading that resource with other civs.
I have had +2 gems when I only had 1 mine and no trade deals involving gems. I have had 0 corn when I had 3 farms and 1 traded to another player.
I have had +2 gems when I only had 1 mine and no trade deals involving gems. I have had 0 corn when I had 3 farms and 1 traded to another player.