Altruism:
Behavior is normally described as altruistic when it is motivated by a desire to benefit someone other than oneself for that person’s sake. The term is used as the contrary of “self-interested” or “selfish” or “egoistic”—words applied to behavior that is motivated solely by the desire to benefit oneself
Socialism is a lot more complicated.
Humans are social animals that forms collectives and that's a rather successful idea, it's increases production by synergy effects way beyond the sum of it's parts. However as soon as you form groups you're prompted with questions of organization, production, distribution, morality, ethics and questions of who or how that is decided.
So these groups could be egalitarian, hierarchical, loose or tightly connected, top-down, bottom-up, a contract, an legal-entity and so on...
Now Europe ended up with some sort of caste system with ruling class (aristocracy) that based it's power partially on titles of ownership of land, military strength (again partially based on feudal systems of loyalty) as well as a narrative of the church of a "god given hierarchy". The second class was that respective church that was somewhere between providing that narrative and being rulers themselves and the peasantry who produced things and served as soldiers.
So a system were people had their place and purpose. Then came the enlightenment and somewhat ripped the veil from this narrative. There were ideological and political struggles that put more emphasize on the individual in those systems. So people were encouraged to think for themselves, the role of a person was elevated from a part in the body/machine of society to that of an individual that was supposed to have a life of it's own.
The power of kings were limited by constitutions, the caste system was eroded and demands of political participation came up. Freedom and equality of people was demanded. A rule of law that applies to everyone equally rather than being dependent on the good will of a ruler. Social contracts and so on.
However liberalism apparently adopted sometimes a rather extreme position of individualism, which encouraged considering the individual as an isolated entity. And early modern socialism apparently originated as a counter to that one, stressing the importance of societies. Rather than the self-sufficient individual their ideal was a free association of equals. Which ranged from contract theorists to utopian socialists and moved more towards the latter group.
And from there it gets complicated because hundreds of people added their two cents on how such a utopian society could look like, how it should be achieved, how it should operate, what should be prioritized by it or in order to achieve it and so on. At first it was also used synonymous with communism or in place of each other, or socialism for collective production and communism for both production and consumption.
That being said, with the industrial revolution it became apparent that the equality that was achieved with the liberal revolutions, was largely a legal and political, but that economic disparity was the new caste system both socially and politically as democracy was still largely a game for the wealthy. With the major culprit of that inequality being identified in the production of goods and more precisely that that the ownership of the means of production marked the demarcation line between the new classes. So the socialist demand was largely to democratize the economy and to collectively own and work the means of production. Again various ideas of how that should work, from worker owned companies, to state owned industry, strong unions aso.
On top of that you had various workers rights movements some socialist, some just concerned with the improvement of the conditions of the working class. Marx apparently ranted against the utopians and tried to characterize the capitalist mode of production and argued that history is a series of class struggles and that argued for a proletarian revolution. He rebranded the term communism to refer to his particular movement and split with the anarchists who also were in favor of such an ideal, but not in favor of seizing power to establish it, but rather would go straight to a society of equals without a period of domination of the revolutionaries.
Though Marx was largely theoretical and didn't saw any of that in application, the closest being the Paris Commune which was gunned down within months. So the first larger applications happened at the end of WWII when the war let to desperation and the lack to fight back opposition which resulted in several revolutions, the most lasting being the one in Russia. There in 1903 Lenin had tried to build revolutionary vanguard party, failed to be effective with it and got exiled. First revolution happened in 1905, introduced a parliament and was rolled back by the czar. Then another revolution in February of 1917 and got rid of the czar and then Lenin was allowed to return and with his party seized power in November of 1917, held elections soon after, lost and took power anyway.
He in this practical application made some significant changes to the entire concept. Redefining socialism to "intermediate state of rulership by a communist party with the goal of preparing for communism" or something like that. And developing economic and political ideas and exporting them to various countries who largely adapted them with local fixes. Meaning when "socialism" is used there's a good chance it refers to one of those systems, despite the fact that this "real existing socialism", is often quite far off from the ideal of a society of equals, organizing their economic production democratically.
So socialism could refer to a utopian goal, to concrete movements, to ideologies, to a transitional state and so on... So it's complicated.
Now how is that different from altruism? Well for a start altruism seems to be an individual thing, while socialism is concerned with a society. They both somewhat acknowledge the existence and importance of other people but for altruism that's a goal in itself for socialism it can be but it also can be mutually beneficial.
That being said it's debatable whether an extremely pure version of altruism is even feasible as there is always some positive side effect in helping others and if it's just the feeling of moral righteousness. So the question is somewhat whether it applies to just the act or the purity of the motivation for the act. Depending on that it could apply to some versions of socialism but doesn't have to.
Like afaik there are literally version of socialism based on a union of egoists, so if everyone acts egoistically and concerned with their own self-interest they keep each others interests in check while mutually benefiting from each other, not sure this works stable like that, but it would be a non-altruistic edge case.
A more interesting question might have been what's the difference between "social" and "altruistic".