The U.S. president has twice attempted to pivot away from matters of Islamic extremism to focus on strengthening ties with other countries only to see events beyond his control land him back in the thick of the terrorism discussion.