In the USA, there are two main ways to establish priority of trademark rights.
The first is by actually using a mark in US commerce to sell goods or render services. Even without a trademark registration, you can acquire trademark rights in your geographic area of use (and possibly a zone of natural expansion).
The second is by obtaining a USA federal trademark registration, which gives you nationwide priority as of the date your application was filed (subject to some limited exceptions). This nationwide priority gives you senior rights as to any subsequent adopters of a mark that would cause consumer confusion. But a federal registration is still junior to anyone who already had prior trademark rights at the time your application was filed.
Doing due diligence on mark availability and filing your trademark application as early as possible is the best way to establish your priority date and guard against others subsequently obtaining rights in a mark that could cause consumer confusion.