Because people were dying in hospitals where there were protocols to protect people from catching it or outsiders coming in. Imagine if everyone got to go into the hospital in and out regularly you could not maintain the environment. Masks are effective at stopping the spread but if you have people coming in and out constantly you need to wash all the surfaces repeatedly and all teh areas where people are because you don't know what happened before they entered with a mask. Hospitals have enough to worry about without filled waiting rooms or hospital rooms with fmaily members all around. it is a pandemic so it makes sense.
Everyone understands why hospitals restricted people from coming in....except a select few of you just to make an argument.
In the cancer ward due to reduced immune systems, people are severly restricted from coming in and out, now imagine a virus situation in a hospital with 8 to 10 COVID patients where the ward has to be sealed off and tons of PPE ar ebeing used hourly.
I think you just want to argue on this rather than think logically why during a pandemic a hospital is keeping people out.