Turkey and Egypt are expanding military cooperation as overlapping security challenges, from Libya and Sudan to Gaza and the Red Sea, bring the former rivals closer together.