First, you're ignoring the basic difference between expenditure and investment. When the government spends a dollar on healthcare, that may be an "investment" in an abstract sense, but the government is not directly getting that money back. In budgetary terms, it's expenditure.
That is not true for the financial bailouts. There, the government didn't just spend money, it got assets in return. With respect to TARP, the government got most of that $400 billion back. It made a nominal profit, and adjusted for inflation maybe you can book it as a $24 billion loss: https://www.nationalreview.com/2015/01/overselling-tarp-myth....
With respect to quantitative easing, what you're referring to is the Fed's SOMA operations. The Fed bought $3.5 trillion in assets (securities and treasuries--i.e. the right to be repaid money in the future). It is getting that money back as those assets mature. Right now, the Fed has about a $67 billion unrealized loss on those assets: https://seekingalpha.com/article/4225750-deterioration-fed-b.... That means the fair market value of the assets is $67 billion less than the Fed's purchase price.
So the actual cost of those programs is the $24 billion and $67 billion losses, not the $400 billion and $4 trillion it cost to purchase those assets. To put those numbers into perspective, the government has a portfolio of $1.5 trillion in student loans. Losses on that portfolio will cost the government $180 billion over the next decade: https://www.forbes.com/sites/prestoncooper2/2017/08/04/why-g....
Second, you dramatically underestimate the cost of those social welfare programs. If we scaled up our welfare system to Swedish levels, that would cost an additional $2.2 trillion more per year.[2] That is five times the upfront cost of TARP ($400 billion), and 100 times the actual cost of TARP ($24 billion). Welfare is expensive. Even if universal healthcare reduces our healthcare spending to German or French levels, we're talking 10-12% of GDP, or $2.3 trillion: https://data.oecd.org/healthres/health-spending.htm. Unlike the financial bailouts, that's (1) money you have to spend every year, not just once-in-a-generation; and (2) money you're not getting back.
Put it another way. Together, all levels of government already spend about $7.4 trillion per year. $400 billion--what the government spent on a once-in-a-generation bailout, was just 6% of what it spends every year. $24 billion--the actual long-term cost of TARP, is just 0.3% of government's yearly expenditures.
[1] Real-world example. Say in 2008 my parents house was worth $500k. The housing market collapses, and suddenly my parents need to sell their house. If they put it on the market, it would go at fire sale, say $200k. I bail them out, buying it for $450k. What was my cost of bailing them out? It wasn't $450k. It was $450k minus whatever I can ultimately sell the asset for. Say the market never recovers and I sell the house for $400k, 20% below the peak. The "bail out" cost me $50k, not $450k.
[2] Swedish government spending is 49% of GDP, versus 38% of GDP in the U.S. https://data.oecd.org/gga/general-government-spending.htm. That 11% of GDP difference amounts to about $2.2 trillion.