Fixed in the upcoming Stardew Valley 1.6.16, which will automatically fix any invalid animal tracking like that when you load the save. Thanks for reporting it!
@Pathoschild when is the new update scheduled to release? I couldn't find any info online. I haven't touched Stardew in over a year since all of my animals disappeared, and I am very eager to get back to my farm. Edit: I play on the Switch, does this update fix the bug on all platforms or just windows?
@deezyfarm There's no release date for 1.6.16 yet.
The fix applies to all platforms (including Switch). Animals which already disappeared are probably gone unfortunately, but you'll be able to resume using affected barns/coops normally in 1.6.16 and it shouldn't happen to any new animals.