The canning process involves heating the sealed tins of food at a high enough temperature and for long enough to sterilise them and kill off any nasty stuff.
If you found some cans of food from WW2 in the woods and they weren't dented and were intact, it'd still be safe to eat whatever was inside.