The jihadist groups are extending their reach, threatening coastal West African states while battling local armies.