Google plans to invest up to $40 billion in Anthropic, deepening its AI push amid rising competition in the sector.