Theyre both.
Benefits were initially concieved as a form of state run workers insurance. You pay national insurance and then you draw out money for certain life events: maternity, retirement, sickness, unemployment.
The "Contributory benefits" still function like that. Things like Maternity Allowance and contributions based Jobseekers Allowance and Employment and Support Allowance.
But the benefit system pretty quickly had to reckon with circumstances that didnt fit into thay mould. What to do (for example) with a person who was born disabled and has always been too sick to work. Even unemployment is a bit tricky.
Contributions based systems are designed for periodic or cyclical unemployment. Not (for example) the great depression. Or the systematic deindustrialisation of the 1980s. You need something means tested to cover a basic standard of living for those who have not paid in.
But apart from that, benefits have always been used partially for social engineering. Child benefit was a way of transfering money from men to women (on the correct assumption that women generally act in childrens interests).
Tax Credits were a way of incentivising low paid work because the Labour Government were committed to a low wage service economy but didnt want society to reap the full consequences.
Universal Credit is largely a way of subsudising housing and childcare through private sector providers.
The benefits system cant perform this function and remain a "safety net" because housing and childcare are long term ongoing costs. Not short term emergencies.
I personally feel that subsidising housing and chilcare is a legitimate function of the state. These things are necessary, hard for individuals to afford on their own and the private sector tends to make a hash of them.
Is providing money to individuals to spend in the private sector is a good way to go about it? Maybe not.
If everyone was paying £350 a month for council housing and another £200 to state subsidised nursery that would represent a similar level of state investment. But it would feel more dignified because the subsidy would be hidden in daily life.