From Silicon Valley to Bengaluru, tech giants are trimming staff to refocus on artificial intelligence, cloud services, and profitability after years of overexpansion during the pandemic.