DDoS Protection and Questions

There have been a lot of questions on here about Dos and DDoS attacks... One thing I've never seen a good answer for is... aside from never downloading peer uploaded files is there a way to protect yourself from stubs.  Will malwarebytes find them with a basic scan?

I know there are ways to protect any server you have from such attacks but I don't understand how that works?  Even if the server blocks the attacking IP's the server still has to respond or view the package in some way correct?

https://en.wikipedia.org/wiki/Denial-of-service_attack#Handling

Cloudflare is pretty decent for handling ddos attacks, but in reality with a big enough botnet you can hit nearly any server offline.