The CEO was facing risks from Trump’s tariffs, Google litigation and the AI craze. He turned to his playbook and now the iPhone maker is worth $4 trillion.