It's not replicating unless you're telling it to make a copy of something that already exists
It is though. The replicator stores static patterns in a similar way to the transporter - they're basically the same technology. To create a new replicator pattern (e.g. a cup of tea) the original cup of tea is dematerialized and the pattern saved for future reproduction. This also explains why some people complain about eating "the same replicated meal" over and over - it's literally true, the replicator replicates the exact same cut of chicken cooked the exact same way with the exact same spice blend every time, because it's reproducing a copy from a file. Even if it's a perfect chicken dinner, it's the same one you've had hundreds of times before.
This also explains why every replicator in the universe can't just reproduce anything at any time. Different models have different sets of patterns available. A restaurant-grade model (like Quark's) might be distributed with a menu of meals prepared by chefs with good reputation and have more space dedicated for storing food patterns, whereas the Starfleet model has a menu prepared by a committee of Starfleet nutritionists (decent, healthy, but not gourmet) and also uses some pattern storage for utility items like uniforms and tricorders &etc (it's general-purpose, not specialized for food, so its food reproduction is comparatively lower quality than Quark's).
Presumably the patterns are not easily interchangeable/distributable - different file formats, different scanner resolution, maybe different output options (canonically some materials are more difficult to replicate than others, so might require a specialized replicator). Quark's replicator, being Ferengi, is probably proprietary and requires purchasing new patterns only from the original manufacturer to increase the variety.