Can be used for carrying stuff too but in these cases, protection. M113 cannot stop HMG rounds (12.7) from the side. Only upto 7.62MM. So heavier sniper and HMG bullets remain a threat, hence the sandbags. Keep in mind sandbags are extremely effective at stopping bullets so even just one sandbag there is going to stop any small arms ammo, it’s obviously not ideal but it’s definitely an upgrade. In PA the other versions of M113 (Saad) have increased armor at the sides too to help with this, and the VCC variants even mount ERA in some cases for further increased protection.
At the end of the day all of this is less ideal than actual Modern APCs, but any benefit is better than none, especially considering the BMPs used by the adversary’s dont fare better in this regard.