This is a risk that that client should be aware of also.
It depends a lot on the situation.
If you're part of a team, it's a critical part of resource management to ensure that there are multiple people familiar with a project and can continue with it or take/over if necessary. It's not good to have only one single person working on a project or knowing exactly where everything is and how it all works. Even if there isn't some big issue, what if someone on the team takes two weeks of holiday? There should be redundancy.
This becomes more difficult if only one person is hired to work on something. Nonetheless, these things can't be helped and the client should be aware of this.
You're taking a risk too
Another thing to point out is that the risk works two ways. What about if something happens to your client and they are in an accident? Then they won't be in any capacity to pay you for your work done.
What to do?
For the contractor:
It would be better for your to spread out your time between multiple clients so that if something happens to one it doesn't have such a big impact on your income.
For the client:
If the work can be spread out between multiple people, then that would help mitigate the impact of one of them suddently becoming unavailable. If this can't be done, being prepared with additional options (other companies/freelancers) in the case of an emergency would help to quickly handle the sitiuation. Additionally, ensure that you've stored somewhere what they've delivered so far to hand over to the backup company.
Just being aware is often enough
In either case, it's important to remember that these things can't be avoided, and that the best thing to do is have a backup plan in place if something does happen. The plan will be different depending on the situation and type of work, but thinking about the consequences beforehand will difinitely help.