If you're not first, there's no reason to publish a paper anymore. And you just lost a good paper... (And paper count is really almost all there is in academia, at least that is what it seems to me sometimes)
Often the next things to explore in research are fairly obvious from what has just been tried.
Colleagues and I started data collection. Submitted a paper and were rejected as another group beat us at a prior conference because they could move just a bit faster. Sucks when a reviewer says "Unoriginal. Already saw this last month."
Ingress wasn't so popular that you could assume people in the same location as you were also playing.
At the height of its popularity, you were the odd one out on the street corner if you weren't playing Pokemon Go.
That’s a systemic problem where we end up chasing the latest fad not because it’s interesting, but merely hoping to end up before someone else. Luckily, not all fields have that short-term outlook.
At a more prosaic level, during my own Ph.D. another group published a paper very similar to one I had been working on. (By a strange coincidence the lead author on that paper had a very similar name to my own.)
There is something to the idea that it's a good thing if you have to worry about other groups scooping your work. It means that you're probably on the right track --- it means your work is relevant and that you have a reasonable path to solving an important problem.
Students are advised to withhold their best ideas from conferences.
My spouse is in a field like this, and "so-and-so got scooped today" is a not unfamiliar dinner table conversation.
For my PhD, I was lucky that my project required a huge pile of expensive and rather unique equipment, plus I really did have a skill advantage for the work I was doing. Two other labs replicated my work using the plans that I supplied to them, but I made sure that I got there first.
To give an example: One idea I've been working on lately is in a very narrow field where almost no one has the background to do it. (I consider myself barely qualified.) Someone publishes something similar perhaps a few times each decade. I'm really not worried about being scooped on this. I've thought before that whatever paper I write on this is basically written for someone a decade or more in the future, as possibly no contemporary researchers will care.
New ideas are worth everything in science, especially when doing experiments.
When I started my PhD in physics our group leader told us repeatedly not to talk to people from MIT or Caltech about our work too early, because there will be a postdoc who will do what will take you about 3 years in the space of 6 months.
Because of smarts, or because of their access to resources?