Saudi Arabia, Turkey and Pakistan signed a defense agreement on Friday that would treat an attack on one as an attack on all three, Turkish and Pakistani officials said, solidifying cooperation between the three regional powers at a time of growing security concerns.