For most of the past two years, the opposite trade prevailed: investors piled into semiconductor and infrastructure companies on the assumption that Microsoft, Amazon, Alphabet and Meta would keep accelerating spending on the buildout of data centers.