Except in this case, they are doing both. To not do what you're asking (not turn over data on abortion seekers), they would be breaking the law if they received a valid warrant.
Now... They could comply with the law by not hoovering up as much data as they do, thereby becoming useless to both advertiser and law enforcement alike....
The companies profit from this data, but at this point they no longer have a choice: they have to collect the data or stop offering services in a lot of geographical areas. The point that they can avoid it by not collecting it was valid some 15 years ago, but no longer.
One of the main objections of companies is, by the way, that most governments refuse to pay the sometimes extensive development and infrastructure costs for this, instead just threatening the companies with (often illegal) measure to force their compliance.