In answer to the title of the question (see the addendum to this answer for details) No, Google does not cause 40% of the CO2 emissions of all Internet Traffic.
There's a case that can be made, however, for the statistic involving absolute emissions.
https://www.vox.com/energy-and-environment/2017/12/6/16734228/google-renewable-energy-wind-solar-2017
From the Vox article,
In 2015, for instance, it devoured 5.7 terawatt-hours of electricity, about as much as the city of San Francisco uses in a year.
If we assume (justifiably, I think) that Google has both grown and worked to improve its data centres' efficiency, let's call it 6.5 TWh.
The US Energy Information Administration pins CO2 generated per MWh at 1041 lbs, or approximately 475 kg. There are some countries where the generative mix is dirtier, but Google's data centres tend not to be located there.
6.5 million times 475 kg is approximately 3.1 MTonnes.
Now, Google buys and either uses directly or makes available to markets enough renewable, emissions-free energy to completely offset its energy use. But if one assumes that its data centres broadly use a mix of sources similar to those in the US, its carbon dioxide emissions per annum would be close to 3.2 million tonnes.
Of course, globally, emissions are something like 33 Gt per annum, so Google's contribution, notwithstanding their work to bring emissions down, would amount to one one-hundredth of a percent of the total. I would say the benefits accrued by having an index of human knowledge are worth that.
Edit, addendum
Additional point addressing the actual title of the question - a fairly well-sourced study suggests that total data centre energy usage in 2012(!) was circa 269 TWh. Even if the total dropped since then, that puts Google at about 2.5% of total data centre power consumption, not 40%.
It's worth noting that the figure could go up substantially if one counts the energy involved in running the computers, smartphones and other devices connecting to Google, but I don't think the argument could reasonably be made that they wouldn't be used were it not for the search giant.