A Mob inside a minecart (minecart is not moving) will randomly give the minecart velocity without a predictable pattern. This means that transporting/storing mobs becomes quite frustrating and also defeats one of the main points of minecarts. The ability to transport and store living things.
To replicate this simply get a mob (villager/pig/etc) inside a minecart and move it on rails. Make sure that the minecart is not moving. After a random amount of time (couple of seconds or minutes) you will see that the minecart starts moving for no apparent reason.
The best way to see this is to get a Zombie inside a minecart (not moving) while at the same time having a villager for the zombie to target. This way the Zombie will cause the minecart to move towards the Villager or if it was already moving away, it will reduce the speed and even switch directions.
The simplest way to fix this would probably be to disable the movement of Mobs inside Minecarts. This makes especially sense since they cant go anywhere anyways.