Well, as all have said, it depends on what your core experience is.
Ideally, game play and story go hand in hand, each supporting each other in a continuous feedback loop.
Sometimes an interesting story will inform a novel mechanic and sometimes a mechanic inspires a story.
What you don't want is one to contradict each other too much, if at all.
In fact, we have an issue right now regarding an upgrade mechanic that I made into a story. A long time ago, we had an idea to use some of a mechanic inspired from another game, the discussion was rather vague, and we wanted to tailor the mechanic to our theme, so I wrote a story, featuring that mechanic, to get it into our theme.
Now, we're finally at the point of coding it in, and it makes more logical sense of just to dispense with the story, and just make the mechanic exactly as it plays out in our inspiration.
Is this a good thing? or a bad thing?
On one hand, we could make it mechanically consistent, yet that would take out the original spin we put on it.
On the other hand, we could keep the mechanic as the story has it written, keeping the theme consistent, but potentially mechanically problematic.
So what's the right answer?
IDK yet.
My point is, a story is meant to inform and engage your player, every mechanic, if done to its full potential could inform narrative and theme, without spelling everything out in a story.
writing story is a continuous process, our jobs as writers are to do our best in fleshing out the world long before anyone else gets to that point in development.
Once the development reaches that point, that is the true test of your team, and how much they respect the writers.
Do they follow your directions as to what was set down, with some or no alterations?
or
do they think writing is completely malleable, and start taking the story in new directions, without your input or even notifying you of their objections before they act?
Sometimes, you'll get those extremes, but more likely you'll get in between somewhere. How do you as the writer respond to that?
Writing is both the most powerful aspect of a game, and the weakest. 1st in, last out.
Your question is more accurately asking what the place of story is in a game, how much power do the writers have over everything else in the game. And by association, whether it's better to have a story before gameplay or have gameplay before story.
Story shouldn't be really thought of as 1st or last in a game, but all over the place, all at once.
The way I personally do it?
write the story 1st, then the gameplay, compare to maintain consistency, rinse and repeat. However, at times, I've looked at the roles needed in the mechanics, and use that to inform what direction the story goes.
What if you write a story about the player flying a helicopter into or out of a war zone, but the gameplay and design mechanics don't go in that direction?
What if you write a story about a stealth assassin, yet there are no silencer wapons in the game?
As a writer, your place is everywhere, yet nowhere, so far ahead, that your behind. So detailed in the descriptions of the scenes, yet the engine nor the artists are able to create it.
A story should both guide yet be transparent. It should both be the backbone of the game, yet also be able to be ignored, It should be so vivid that no one will see, and so clear that if missed, it can adapt.
It should provide the setting, and also provide the details.
It should be so good that 2 concept artists reading it, can provide both an identical image and a disparate version. So immersive that it is everything and nothing at the same time.
So clear that readers can have different images of the characters and settings.
So,
Q: does story come 1st or last in a game?
A: Yes.