I am also having this issue. So far it has only been with pigs, both adult and baby. The cows have remained in their fences.
Removed my previous comment. I misread the details.
I, too, have this problem except with chickens and villagers in areas where I have removed blocks then replaced them with the same block. The only solution I have found is to kill the NPC.
This still happens in the latest snapshot, 13w09c.