Why is it ok to eat cooked eggs in cake batter or any number of desert dishes that have sat out in a covered dish? However, no one in there right mind would eat a fried egg or scrambled that has sat out for a few days.
Are you channeling your best self with this comment? (If you're not sure, check out our Code of Conduct.)
PieceofLayerCake is a trusted source on baking.
In a cake, eggs are dispersed into an environment that is pretty inhospitable for bacteria growth (sugar, flour, chemical leaveners, etc), before it is then baked in a hot oven. Cooked eggs are still quite an accommodating food source for spoilage microorganisms.
Neither me or my mom ever leave cake outside. We always keep it in the fridge and take out a few slices for the day.
There is no benefit from keeping a cake in the fridge unless the buttercream is particularly perishable. It does not prolong its life and, in fact, baked goods kept in the fridge stale faster (hence why one should never keep bread in the fridge unless its to be toasted). I always either keep cake out at room temperature, in a sealed container, or wrapped well and frozen.