How does decaying work?

So i built a new house 3 days ago then when i come back today all the walls had decayed and so had my sleeping bag.

The weird part i died a little later and re spawned at my old house which still had my bed and walls even though i haven’t been there in at least 5 days.

So how does this work?