The president’s misinterpreted comments about Los Angeles and San Diego created opportunities for his foes and confusion for his allies.