The country is facing what law enforcement officials call a complicated threat environment caused by a surge in hate crimes, heightened emotion from two wars abroad, and the political climate at home.