Beds/Defenses keep "disappearing" when not in the settlement
I have seen this extensively during my multiple playthroughs and believe this to be a bug of some kind. As you've noted, visiting the settlement and looking at the statistics in workshop mode reveal the correct numbers and once you've seen these numbers they'll be correctly reported in the Pip Boy interface.
This isn't limited to specific settlements and as far as I have seen, not related to specific events either (it's not going to happen more frequently if, for example, that settlement has just been attacked).
I have not found a method of ensuring these numbers are correct without visiting the settlement.