The attacker watched videos ‘glorifying martyrs and jihad’ immediately before the stabbing, the official said.