You are allowed to do what you please with your things within the confines of the law. A government creates laws to promote the wellbeing of the populace. In this case, they decided that it's no longer lawful for Google to set a default browser, so Google shouldn't do it anymore.
The difference here is that you did not create the town. It is publically created and publicly owned. Your rights and privileges ends where someone else's begins
> A government creates laws to promote the wellbeing of the populace
Yes, but it does so by creating an environment where individuals can choose for themselves what wellbeing means to them
It might be legal for a government that is driven by populist and protectionist agenda to target the useful and unique inventions of foreign companies but it isn't fair and it infringes on the natural rights of these companies.