Battlefield clearance was the final phase of battle in the ancient world just as it is today, with some differences. Friendly bodies would be removed for burial or cremation depending on cultural preferences, and enemy bodies would be stripped of whatever equipment and weapons the conquering army fancied and often left naked on the field.
The ancients had ample opportunity to observe the effects of rotting on human bodies and understood a clean water supply as an important tactical consideration in a campsite, and so if they planned to keep their camp near a battlefield they would probably clear the bodies. However, an army would generally move their campsite after a battle, as the purpose of the original campsite would have been in preparation for the battle that has now occurred, and the army is now free to engage in other operations.
The locals would no doubt check a battlefield out to see if there's anything worth taking. Much like an army, if the bodies were of their countrymen and especially if it was near their settlement they would dispose of the bodies in a manner befitting their culture, mass burning or mass burial. I have to add that, oddly, we've never found such a mass grave in Europe from any ancient battle. So maybe bones don't stick around under those circumstances, or maybe mass burning was the norm. I would personally assume the latter but I have no source for that; it only seems sensible considering the work it would involve.
I should note that Cannae was highly unusual, and major pitched battles with large casualties were unusual in general throughout human history. So this problem would not have come up very often, and it was probably dealt with differently every time, depending on culture, the circumstances of the battle, proximity and relationship between the locals and the victorious army, tactical considerations for the army (stay put or move on), etc. As major battles tended to be fought near major settlements (hence their names), I have no doubt that people would have understood that there were risks associated with leaving the bodies to rot. These risks might have been framed in religious terms more than medical (the shame of being defeated in war and leaving stripped bodies on the field), but there were certainly motivations to clean the place up or otherwise steer clear.