This is a bug in Magento but it will not create any issue at frontend.
In normal case, when you assign products to category then those products will be linked with that category and linked product count will be increased for that category. And if you unlink that product from that category then linked product count will be decreased.
Now problem will be arise when you delete product from catalog->product section. Still category will have entry for that product. So old product count will be in category OR After importing or upgrading database, you may face this problem.
To fix this, you need to run following SQL query:
Kindly, take database backup before running query to prevent accident deletes.
DELETE FROM catalog_category_product where product_id NOT IN (SELECT entity_id FROM (catalog_product_entity));
It’s Tested & it will work 100%.
Hope you understood well.!