True, though a key difference is retailers (Walmart especially) aggressively negotiate against manufacturers to lower prices. For high end manufactured brands sold in retail, like soap, trash bags, etc., store brands are created by competing manufacturers in part to add negotiating leverage against a P&G or other major manufacturer. And there are few CPG categories without significant competition.
With pharmaceuticals, production capacity is hardly an issue. It will, ironically, cost Mylan more to make the "generic" new brand (pay for new branding, packaging, etc.) than it will to make and package the existing brand.