That's a little bit off.
Read https://ssir.org/articles/entry/the_truth_about_ben_and_jerr... and skip to Legal Landscape.
The article as a whole is about Unilever betraying the corporate values after buying the company and whether the sale was really forced, but that particular section goes into detail why what you're saying isn't universally true.
The TL;DR is that a number of state laws (and possibly higher level, hadn't finished researching) specifically carve out room for companies to consider corporate values over investor money in fulfilling fiduciary duty. They establish multiple classes of people--including customers--to be constituencies being served, not just investors.
So you can absolutely incorporate in a way that will run your company to make as much money as possible for public shareholders within the bounds of what makes the company that company, including value systems. If a company betrays their stated values, that's absolutely on that company, not an inevitable fate for going public.
Relevant quote:
Most state legislatures have resisted the tenets of Dodge v. Ford by enacting statutes that expressly authorize corporate directors to look beyond shareholder wealth maximization. Vermont enacted one, nicknamed “the Ben & Jerry’s law,” after the company had successfully lobbied Vermont’s legislature. Vermont’s “other constituency” statute, as these laws are called, is illustrative: It provides that when directors make decisions they may consider such matters as “the interests of the corporation’s employees, suppliers, creditors, and customers; the economy of the state, region, and nation; [and] community and societal considerations, including those of any community in which any offices or facilities of the corporation are located.” State statutes also give corporations wide latitude to donate profits to charities.
Edit: having problems finding a clear list, but looks like ~35 states have them, including Delaware. California, interestingly, does not have one. Looks like one made it through legislature years ago when these were all popping up, but Schwarzenegger vetoed it.