It is solved by producing what is needed, rather than what will bring profit. The socialist economy usually has production of what is needed according to supply and demand. They don't make more things or less according to their value, but rather they will invest in what the society needs.