The idea of communism/socialism assumes that if society produces enough food/clothing/etc. for everyone, then why not just redistribute it fairly between everyone instead of relying on money. Socialism assumes that resources can be redistributed by government policy alongside otherwise capitalist system, while communism prefers to get rid of personally-owned-capital completely.
It has it's fair share of problems like usually not taking transportation into account or assuming that if one person needs half a pound of meat a day then another needs the same. It generally requires politicians to run the country like playing a game, game where goal is to make sure everyone has at least basic needs covered. Usually this backfires for the same reason capitalism turns into shithole - people are greedy and incompetent.