Typically if a company wishes to do business with EU residents they have to comply with the EU regulations. Many larger companies choose to incorporate somewhere in the EU to make this easier or in some cases they will even incorporate in each country that they do business in.
This might be a shocker, but even American companies have to obey the local law of the country they operate in. Big tech runs offices, has infrastructure and profits of a huge market in those countries. All of this is leverage a country can use to enforce their law.
Or, if they wanted to go all out, could issue EU wide arrest warrants for top Google and Facebook executives, and start seizing their assets. I’m sure top exec at both companies have a bunch of holiday homes on the south coast of France they like to visit.