Should PhD students be goal or opportunity driven?
Although naturally the details of the landscape differ from subject to subject, here is my picture from mathematics:

In addition to the obvious point that one should "both" stay focused on a long-term project and be alert to incidental opportunities, I would claim that the best kind of thesis projects (and projects in general) are those that help create incidental opportunities along the way to a worthwhile large-scale goal.

(This in addition to "educational" benefits of well-conceived projects.)

The obvious hazard is to get distracted from a reliable, long-term project by too-speculative "cooler" possibilities one encounters along the way. The hazards here are like "... but don't quit your day job" as advice to aspiring rock stars, etc.