There was news before that the trademark someone had been using for more than 10 years had been registered with another company without noticing. In conclusion, trademark registration can be done later after seeing someone else using it.
The Japanese trademark system employs two methods: the "Registration Rules", which grants trademark rights only to those who have registered the trademark, and the "First-to-file Rules", which allows the person who first completed the trademark registration procedure to register the trademark. It doesn't matter which one actually started using it first.
As a remedy for those who have been registered as a trademark later out by others, there is a "right of prior use" that allows the trademark to be used continuously if certain conditions are met.
However, If you want to use the trademark continiously, the best defense is to complete the trademark registration yourself before someone registers it first.