Impact of Redundancy on Resilience in Distributed Optimization and Learning