If they had kept their distance, they probably wouldn't exist today. The dependency on government has been critical for any tech company. They'd have been replaced by a different company that is willing to cater to the government's every whim.
That said, the founders of these companies could have lobbied the government to ban corporate lobbying.
It's like; if there's gov money on the table, then it'd be a mistake to let your competitor take it. However, if you ensure that government money is never on the table for anyone, then that's one less thing for everyone to have to compete over and throw money at. Everyone can save their money for other things.
The government should never have allowed political lobbying to become a competitive market.
Also, political campaigns should not be allowed to raise private funds. That is insane. The government should fund all candidates' campaigns and allocate equal funding. Candidates shouldn't be allowed to spend their own money on their own campaign either IMO.