Like most decisions, it's not black or white. Bigger companies (especially in regulated industries like health care or finance) are not going to write their own versions of ERP or HR software because of complexity, regulatory, and compliance requirements.
But smaller companies that need a "lite" version of a SaaS, might write their own, unless they target this need.
Also, in this period of turbulent change, if SaaS companies don't keep up with the evolving needs of their customers, and large gaps open up between what they offer and what the clients need, they will be more tempted to create their own apps.