States can act differently to different things. Hamas cannot be a friend of any secular state. Islam does not concider Jews as infidels. Past Israeli and Turkish governments saw the wisdom in friendship. These two governments are extremist in their own rights. Israel's Gaza policy is defective. Erdogan will use this internally to enflame the predominantly muslim polulation to divert their attention from his corrupt govvernment. So answers are not so easy.
EU's Mogherini in Tehran to talk nuclear deal, regional issues (Reuters)
from the article: Israel worried by new Turkey intelligence chief's defense of Iran