Generally Social Security and Medicare are not considered to be welfare.
Speaking of Social Security, I did an interesting calculation. If each year starting with the year I first paid Social Security tax the government had taken that money each month and the matching amount my employer paid and put that money in a one year T-bill, and each year rolled the maturing T-bills over into new T-bills, that would have grown enough that by retirement it would be enough to pay my benefits for close to my expected remaining lifespan.
It was surprising how well it matched although I think it may be coincidence. Benefits go up if you had higher income when working and down if you had lower income, but it is not linear.
Someone with half my income would have benefits lower than me, but their benefits as a percentage of their income would be higher and so T-bills wouldn't have earned enough to cover them [1]. Similarly for someone earning twice as much as me T-bills would have earned more than needed to coverer their benefits. I apparently came in right at the spot where it balances out.
[1] Your benefit is calculated based on the average monthly income for your 35 highest income years. If your monthly average was M, and you become eligible to start collecting social security in 2025, your benefit at full retirement age is the sum of:
90% of the first $1226 of M
32% of the the amount from of M from $1226 through $7931
15% of the amount of M over $7931
For this calculation past year incomes are index for the cost of living. For example in 1986 I earned a nice round $42 000. That counts as $161 537 when doing the calculation of my monthly average.
If anyone is curious you can get the adjustment factors here [2].
[2] https://www.ssa.gov/oact/cola/awifactors.html