I have spent extended periods of time in both places. It really depends on where you are. There are a couple of places in Nigeria where I was more concerned about my safety than any place I was in Afghanistan. Those places were Lagos and Port Harcourt. In Lagos, my concerns were due to the number or people living that and the poverty. Being a westerner made in a large visible target. Part Harcourt was due the rebel activity.
In Afghanistan, at least among the various pilot groups there, we tried to look out for each other. To a much higher degree than in Nigeria. In both countries I lived on the local economy.