Your inventory size changes so that there's always some empty slots!
Mods introducing new content into the game.
Play it your way.
Items with an equipment grid (Trains for example in Krastorio 2) don't stack with each other even if their grid matches exactly but only add inventory slots when their stack count is reached.
Thanks for the report!
That sounds a bit annoying to fix though. Maybe it will happen some day :(