Christopher A. Wray, the director of the Federal Bureau of Investigation, paid a rare visit to sub-Saharan Africa this week to discuss counterterrorism strategies with regional partners at a time when both the Islamic State and Al Qaeda are gaining momentum on the continent.