The first situation isn't preventable. The second is. Advance directives are a combination living will and power of attorney. Your patients can write them long before the need arises. It allows them to appoint someone to make medical decisions for them when they cannot.
Advance directives are especially pertinent for care near the end of life.
Family members are very often put in the difficult position of making decisions, under incredible stress, about extending life-sustaining, though marginal, treatment for a loved one. If family or a close friend is not available, there could be no way of finding out what the patient would have wanted. A recent poll indicates that advance directives sound like a good idea to a clear majority of the public. Yet most people have not prepared advance directives. That is a glaring failure of the health care system that must be addressed.