In his first visit to the country as Pentagon chief, tacked onto a larger diplomatic trip to meet with U.S. allies in Africa and the Middle East, Mr. Mattis pulled no punches over the state of the fighting.