It depends on the jurisdiction.
In first-to-use jurisdictions like the US, prior commercial use can form the basis of a legal challenge to a later registration. If a business can prove it was using the mark in commerce before the trademark application was filed, it may be able to have the registration cancelled or restricted to the geographic area where the later applicant has used it.
In first-to-file jurisdictions like the EU and UK, the position is more limited. Prior unregistered use can support an opposition or invalidity claim in certain circumstances, such as where the earlier user has established a reputation significant enough to constitute passing off, but it is not as straightforward as in first-to-use systems.
In both cases, the strength of the claim depends heavily on the evidence of prior use: how long, in which markets, and in what classes of goods or services. These cases are complex and the outcome is rarely certain without professional advice.