RPGs are improv
TTRPGs are a game of improvisational theatre, played between the GM and players, mixed with some math rocks.
As the GM, your job is to portray the world. To do this, creating a consistent world that doesn't look like it is being made up on the spot is one common and great way to handle it. To this extent, you do world building "behind the scenes" and have things connected that the player's don't experience.
However, anything you haven't said to the players isn't part of the world portrait yet!
You are free to revise stuff the players haven't seen. (You are even free to revise some of the stuff the players have seen, in that everyone makes mistakes). And if you do it with art, the players need never know.
Nobody can prepare for everything
GMs who try to prepare for everything a player could do are doomed. The style of play known as "railroading" sometimes results from a GM who doesn't know what to do when PCs don't follow the path the GM has prepared; honestly, it is often less work to force the players down a railroad than it is to handle PCs doing what they actually do.
Improv isn't anything goes
The fact it is improv doesn't mean that you make up everything as you go along. It means you figure out what the other members of your improv group are interested in and you either run with it, or you sit back out of game and you talk about it not being where you want the game to go.
You may have heard about session 0 and red cards. This is about framing the kind of game you want to play - will there be explicit unaliving of pre-adults? Other kinds of mature content? Will it be a silly game, a serious game, a mixture, or something else? Is it combat-as-sport or combat-as-war? How rigid is the plot?
Those are examples of talking about the game outside of the game. But this can and should happen after the game starts as well!
So, you can decide you don't want to explore the plotline they want to explore, and you can nip it in the bud. There are good and bad ways to do this.
However, in this case, I think it is a waste.
Preparation is key to Improv
The preparation you can do in an improv game isn't "here is everything that is going on". You can create NPCs and relationships, you can create locations, you can even have an idea of what is going on behind the scenes. You can have pre-planned "clues" for what is going on behind the scenes to show to the players when opportunity strikes.
If you keep track of what the players actually do and see, and what they are interested in, you can change the behind the scenes details to be consistent with what they see and highlight the parts that they seem to find interesting.
Like, there might be a potion seller who you planned has a minor clue about the necromancer. The PCs might get obsessed with the potion seller, taking a minor statement the make as indicating they are more important to the story than they seem.
In response, you could ignore the PCs obsession and cut it off -- but players being interested in the world is a resource for GMs to use. Simply saying "nope, wrong guess" wastes that valuable resource.
So you can either improvise that "yes, this potion seller is more than they seem" - maybe keep it vague initially, then between games work out a way to change the plot to make the potion seller more important - or you could "nope, wrong guess" them by dead-ending their investigations and then later on reveal they where right all along (in a way consistent with everything they experienced!) for an extra cruel twist of the knife.
Specific advice
You have players invested in the story. This is a resource you should exploit.
It is true that the story of "a single enemy got in, and somehow caused a huge problem" is over-used in fiction and not really all that plausible. Making a plan like that is frankly stupid because of all the things that can go wrong - why would the villagers not just kill the sick goblin, for example? Why would the sick goblin not be watched as a hostile?
The goblins planning to find a sympathetic idiot, bypassing security, then being able to coordinate an attack with that goblin escaping within the town, is seriously implausible. The number of things that would have to go right in a row for that plan to work is huge, and if things go wrong the goblin doing the acting dies (and possibly also the team breaking into the town).
It is the kind of thing you get in a heist movie, but heist movies only work if the writer of the movie is on your side, or if you are willing to have a 10% chance of success because there is no alternative but death.
So "yes, and..." your players!
They are looking for something bigger. You can now get them invested in details of your town (which you can invent!) They can meet with one or more NPCs who will betray them later, generating valuable resource of "player hatred". They can meet with NPCs who are friendly and who both need help and are helpful, generating the valuable resource of "player attachment".
You found a gold mine. Don't bury it.
Create a new plot around what is actually going on. The couple are scapegoats, framed by whomever is the real mastermind. The real mastermind might have used the goblin as an event of opportunity, to their plans to let the goblins in on and deflect blame. Possibly the goblin was actually killed, or was freed/chased out by the mastermind.
Why the goblins where let in? Maybe the mastermind needed the chaos for some other crime to be covered up. Maybe the mastermind needed a place burned down so they could acquire it cheap. Maybe the mastermind needed to steal something well guarded, and the goblins got it for the mastermind. Maybe the mastermind wanted revenge on someone and the goblins killed them.
However, I do like the idea that the goblins raiding was just a distraction for what the mastermind really did.
So the mastermind:
Saw the injured goblin being cared for. Aha!
Made a deal with goblins outside to raid.
Let the goblins in, freed the injured goblin in order to attach blame to someone else.
While the goblins are raiding, used the distraction of the raid to advance their foul plot elsewhere.
Faked an alibi for 4 by somehow being seen defending against the goblins (illusion? someone else in a disguise?)
So the players can find evidence of (4), and maybe evidence that (5) was faked, plus the fact that (3) wasn't the injured goblin (maybe a timeline problem - the injured goblin was freed after the gate was opened?!)
That provides a line pointing at the mastermind - motive (4), opportunity (5), and eliminating other suspects (3).
I never thought you'd figure it out
After they figure out the plot that they actually invented for you.