You are thinking about this backwards.
The landlord doesn't set their rent at whatever they need it to be to cover their costs.
The tenants collectively set the maximum rent for the market based on what they are able to pay.
Doesn;t matter what the cost to the landlrd is - landlords can't push it any higher if the money isn't there to pay it.
So potential landlords start by looking at the achieveable rent and decide whether it will cover their costs or not.
Yes once a landlord is in, if an additional cost comes up, the LL can try to pass the additional cost on by raising the rent. But they run the risk of losing their current tenant and not getting anther one - it's not a given their tenants can suddenly cover higher rents just because the landlord's costs have gone up.
Just as when food goes up, some people may pay more for the same food but others may already be at their limit so their only choice is to pay the same amount as before but get less for it. And some tenants, faced with a rent increase, will downsize/move areas instead.
In other words, the ultimate limiiting factor for both rentals and purchases is not what the LL or the seller wants to get, but whether any tenant/buyer is able and willing to pay it.
After all, landlords who bought years ago and so have very low costs don't go round charging less than the market rate, do they?