Two recent attacks by men with connections to the military placed new focus on efforts to combat extremism in the ranks.