One can very simply define socialism and communism as movements in opposition to capitalist society and in opposition to the development and effects of capitalist society. Both of these terms can be used to mean the same thing, which runs contrary to defining that often takes place by capitalist sources. There are also potentially left-wing sources who often operate off of incorrect definitions. I will get into the history of the distinguishing between these terms after first addressing the historical origin.
Originally, fairly early on in capitalist development, there were quite a few different individuals and groups that would later be labeled by Marx and Engels – and still often known today – as Utopian socialists and communists. These were groups mentioned in the Communist Manifesto associated with individuals like Robert Owen, Saint-Simon, Charles Fourier, and others. Although the meaning and usage of the terms developed and got picked up over time and those “Utopians”, as mentioned in the Communist Manifesto and elsewhere, were not the first to coin and/or use the terminology, it was from the influence of those movements, and most notably Karl Marx and Friedrich Engels with their works, that the meaning and ideas developed and became prominent within the modern context.
Going back to the development of distinguishing between the terms, we can, again, go back to Marx/Engels. When asked about why it was called the “Communist” Manifesto and not “socialist” – this is taken from the 1888 English Edition Preface – Engels gives the following explanation:
“Yet, when it was written, we could not have called it a socialist manifesto. By Socialists, in 1847, were understood, on the one hand the adherents of the various Utopian systems: Owenites in England, Fourierists in France, [See Robert Owen and François Fourier] both of them already reduced to the position of mere sects, and gradually dying out; on the other hand, the most multifarious social quacks who, by all manner of tinkering, professed to redress, without any danger to capital and profit, all sorts of social grievances, in both cases men outside the working-class movement, and looking rather to the “educated” classes for support. Whatever portion of the working class had become convinced of the insufficiency of mere political revolutions, and had proclaimed the necessity of total social change, called itself Communist. It was a crude, rough-hewn, purely instinctive sort of communism; still, it touched the cardinal point and was powerful enough amongst the working class to produce the Utopian communism of Cabet in France, and of Weitling in Germany. Thus, in 1847, socialism was a middle-class movement, communism a working-class movement. Socialism was, on the Continent at least, “respectable”; communism was the very opposite. And as our notion, from the very beginning, was that “the emancipation of the workers must be the act of the working class itself,” there could be no doubt as to which of the two names we must take. Moreover, we have, ever since, been far from repudiating it.”
After having faded a bit, around the time of the First World War, when socialist and communist ideas and sentiment started coming back into relevance, especially with, e.g., the eventual establishment of the Soviet Union, there were similar disagreements over approach and radical (versus liberal) dispositions around Social Democratic parties in various countries. Both the Communist Party in the Soviet Union, as well as in Germany, developed out of the Social Democratic parties in those countries. It is probably the easiest to think of the Bolsheviks and Lenin in Russia and the Spartacus League and Rosa Luxemburg in Germany.
There is also the aim of the elimination of capital, as a social relation, and/or private property. This further adds to the distinguishing factor between more radical and revolutionary socialists, who often have taken the label of communists, versus various liberal and/or bourgeois socialist movements. Communism, itself, can often be seen as that goal or aim for the elimination of the capitalist social relation. In turn, that can create another popular confusion where a “transitional” period – where capital has yet to be eliminated – is called socialism. Socialism, in that case, is used to describe an instance – in contrasting it with communism – where capital has yet to be eliminated; or, within a person’s ideological framework where the elimination of capital is not an urgent (or primary) aim.
So, whereas, socialism and communism can be used interchangeably, they have usually be distinguished, historically, by more radical individuals and groups, specifically those who see the immediacy and importance of eliminating capital/private property, adopting communism as a description. The more generic term is socialism used by a wider variety of people with a wider variety of beliefs, including the more liberal elements who might be significantly right-leaning and opposed by left-wing socialists and communists.