The world's second most valuable company has been the top beneficiary of an AI-driven spending spree by big technology companies over the past two years.