A global memory shortage is putting pressure on Apple’s supply chain, and even its long-term agreements with major suppliers may not be enough to keep costs under control.