It seems that the state acquires a prominent position in the socialist phase, but it isn't clear what function it has or what happens to it in the communist phase. — Apollodorus
This is more of a Leninist idea and of course critical to Soviet understanding of Marxism (obviously, Soviet Union believed in an important role of the state).
However, Marx had good things to say about the Paris commune, which was what we'd call direct democracy and what Marx called the proletariat managing their own affairs.
Marx had a fierce dispute with Bakunin, who was essentially the Castro of his time advocating daring revolutionary acts to overthrow states. Marx satirizes Bakunin's idea he needs only 100 revolutionaries to bring about socialism, which, to be clear Bakunin actually says
There need not be a great number of these men. One hundred revolutionaries, strongly and earnestly allied, would suffice for the international organization of all of Europe. Two or three hundred revolutionaries will be enough for the organization of the largest country. — Bakunin, The Program of the International Brotherhood, 1869
So, Marx's view is much more nuanced than just daring acts of what we'd call "communist revolutionaries" in the 20th century, which of course brings up the matter of your OP.
Can anyone explain what is meant by concepts like the “withering away of the state” in Marxist theory? — Apollodorus
This is concept more associated with Proudhon, which Marx doesn't like to credit with anything, so (possibly due to intellectual arrogance) he never makes it abundantly clear he believes the same thing.
But the basic idea as expressed by Proudhon, is that what matters is the beliefs of the people and awareness of the working class of their ability to organize.
The communist manifesto repeats this theme in the idea that the communist is always a friend of the working class and always helping the working class in their struggles of the moment; so, this is very clear incrementalism. At the same time, the communist manifesto makes very bold assertions and talks about revolution a lot, and makes clear that's the goal, so we could interpret this as a call to violent revolution right now or a more mundane "social revolution" as we'd understand our social activists of today (Bernie Sanders sense of "revolution"; profound change but not necessarily immediate or super violent).
Of course, our mundane social activists of today following Bernie Sanders, for example, are only mundane because democracy does actually exist (even in US democratic change is easier than violent revolutionary change, as the Bolshevik style storming of Capital Hill shows us). If we contextualize to Marx's time, politics was of Europe was simply more violent as a matter of fact. So, though we expect from our intellectuals today to condemn violence, it was more just a mundane fact of political life, which Marx, as a political realist, accepts as an unfortunate part of political life and doesn't really advocate against but doesn't really advocate for more of either, as his opposition to Bakunin makes clear.
We can easily interpret the "withering away of the state" as the social democratic process of Europe. Individual citizens in Switzerland and Nordic countries for instance, can genuinely be argued to be free from state oppression and managing their own affairs through fair, or then fair enough, political process. As local awareness increases and local political entities take more active rolls of government management, the "state" becomes less and less relevant to political life; Switzerland's complicated power sharing and power nesting of cities and cantons with direct democratic initiatives possible at every level, that really are effective democratic power, make the Swiss "State" extremely limited in its power and (if you go to Switzerland) no Swiss citizen talks about being repressed by state power.
Of course, Switzerland is wealthy and does have a market, and therefore advanced as a "de facto capitalist success", but this is assuming state capitalist policies maintaining capital's dominance (in opposition to real democratic participation) is the source of Switzerland's wealth in the first place. The counter argument is that real effective democracy brings political stability, little interest in costly wars, good management decisions by the people of "their own affairs" which creates conditions for the accumulation of wealth and an easy time for working class people to, through democracy, ensure decent access to wealth in the form of free education, free health care, good public infrastructure everyone can enjoy, and excellent worker rights to protect against oppression on the job.
If we carry this social experiment of Switzerland, the Nordic's, New Zealand, forward, it is possible to imagine "the State" becoming less and less important, until it is, maybe nominally there as an administrative body of regional issues, but does not and essentially cannot exercise any real oppressive political power. Contrast this, of even the state of affairs of these countries today if you prefer not to speculate about the future, with the French Monarchy, the Tzars, "Communist" China, Nazi Germany, or the Roman Empire for that matter, and it gives a pretty good idea of what "the State" can be in terms of both centralization of power and capacity to oppress. Compared to these states: Nordic countries, Switzerland, and the like essentially don't have states with power over the working class noticeable on any non-logarithmic scale.