That's completely up to your provider, and ultimately, your selection of a provider.
Any shared platform carries risks of your neighbors on the platform causing problems for you. In the case of a DDoS, the shared network infrastructure they're using was probably overrun.
Ideally, they would work with their upstream ISPs to drop the traffic before it arrives and saturates their infrastructure, so that only the target of the attack (and not all the other customers on the infrastructure) would be offline. They may have done this, just not quickly enough, or the attacker may have changed targets.
It sounds like you've already arrived at this conclusion, but, the answer to how to avoid getting affected by a DDoS against your neighbor on a shared platform has to be one of:
- Don't run on a shared platform.
- Run on a shared platform that is better at handling mitigation of this kind of attack.
- Or at least run on a shared platform that covers this kind of attack in their SLA.