Social Security is paid out entirely by proceeds from people paying into the system. If ever the number of new people paying in is not enough to cover the outflows, then the system collapses. That is how a Ponzi scheme works.
If, for instance, we get rid of the contribution cap tomorrow, Social Security becomes 100% funded - in perpetuity.
Madoff was in no position to do so. Congress is.
Again, I'm not arguing for or against Social Security, just whether or not the original analogy is apt. If it's not, it does no harm to those arguing against Social Security unless the argument relies largely on the analogy being sound. I can't imagine that's the case at all. If it is apt, I think it likely can be expressed in a way that more clearly shows its intent.
By buying stock in a given company you increase demand for that company's stock and increase its value. A company's market cap is a very real thing that allows it to engage in economic activity that it would otherwise be unable to execute on.
Buy a lump of gold for $100 and turn it into a $110 bracelet -> value created.
Buy a lump of gold for $100 and sell it to someone 1 second later for $110 -> no value created.