It sounds like you are looking to build a longer term campaign out of a relatively short and linear plot line (Goblins attack at the behest of a larger, nearby Hobgoblin army) - THAT'S TOTALLY DOABLE.
The PC's don't have to go directly from helping villagers chase off some goblins to defending Helm's Deep. There are plenty of things they can do to stretch the plot line out. The invasion proper could be weeks, months, or even a year away (come spring, when the mountain passes are clear) - the goblin attack could be a mere scouting mission gone awry.
1) Side quests. Maybe there are nearby allies that the PCs can attempt to bring to their side and defend the town from the army, but they might need some persuading.
- A druid needs help destroying a witch who is blighting the forest
- A neighboring town/city will send its cavalry to assist IF the PC's can locate the kidnapped princess (turns out she just ran away with a super cute traveling minstrel who put her under a spell, once broken she will return)
- Some local dwarves will build siege engines if you can help clear their mines of some pesky monsters.
- A local priest asks for help gathering some herbs from a particularly dangerous swamp to stockpile healing medicine for the coming war
- Anything you can think of - a great way to introduce the PCs to a variety of local factions and NPCs and introduce them to your world in general
2) Make the PC's the hurdle for the army! There are a lot of things the PCs could do instead of attacking the army head on that could slow their advance once they are on the march
- Lead a dwarf team to create rock slides and close mountain passes to block the army's advance, except through a region where ambushers have a huge advantage!
- Destroy some bridges and buy valuable time for the town while the army has to slowly ferry across
- Attack supply wagons or a rear column of siege equipment to stall the advance/attack
Anything you want can be inserted into this sort of blank slate, you just need to apply a little creative juice and see how it can mesh with the broader plot line of the hobgoblin army.
Last bit of advice, go find a copy of Heroes of Battle (here:
en.wikipedia.org/wiki/Heroes_of_Battle) - yes, it is 3.5 Ed book but it covers a HUGE number of topics, ideas, etc that apply to a "wartime" game. You will find it interesting in helpful for what you have in mind, even if you can't copy/paste the stats directly into your 5e game.