The economics in the Star Trek universe is a utopia, at least in the Federation of the United Planets. It is indeed a system without money, money no longer exists. Food is synthesized by using machines. There are no more poor, no more misery, no more hunger.
The Federation nevertheless maintains a trading medium to exchange goods with empires, other republics or monarchies in the galaxy. This means of exchange can be dilithium, antimatter, plasma, or food.
Thus, food, but also energy, housing and water are free. The vessels operate with almost infinite energy. We may think that it is the same on Earth.
The currency began to have a less important place in the functioning of the Federation in the 22nd century. It totally ceased to be in the 24th century. The new world economic order has been developed at the end of the 22nd century.
In 2364, Jean-Luc Picard explains to a financier of the 20th century that we don’t need any money nowadays, that many things have changed in 300 years, that people are no longer obsessed by the accumulation of things. That hunger has been eradicated, as well as the need, and willingness to possess. The acquisition of wealth is no longer the force that drives our lives. People work to be better and make mankind better.
Materialism is no longer in Star Trek.
There are a lot of times when the characters talk about buying a certain thing, selling a product or offering to teammates to buy a glass, etc … even during the 24th century. It may just be expressions, ways of speaking.