it's not quite apples/apples, and the law tries to protect minority shareholders from unfair actions by majority holders, but if the major stakeholders can say "it's in the best interest of the company" with a straight face and not just so the major stakeholders can enrich themselves at the expense of others, it's usually passable. in general, you'd ask lawyers a lot of questions about this, and you definitely take into account the risk of a shareholder lawsuit.
so, it's a lot easier to do this kind of thing when there's a downround and the alternative to these terms is the company shutting down - basically, the new folks diluting old folks can say this is ultimately in the best interest of the company because the alternative is a shutdown.
in the context of MS or FB, both companies were on the up and increasing in value, so harder for the big stakeholders to say pushing out another SH was just about "serving the best interest of the company" with a straight face.