Alphabet beat earnings as advertising and cloud growth strengthened results while the company plans massive AI spending to expand infrastructure.