Al-Qaeda in the Islamic Maghreb or a related extremist group is thought to have targeted the US troops, in an attack that highlights an incoherent US policy in West Africa.