I've seen this plot multiple times, the main character (either alone or with his squad) arrive into a village where there's no warriors but they face a menace, it can be monsters, bandits, raiders, criminals, etc. So the MC teaches them how to defend and most of the time it resolves with the village beating their attackers.
Examples like these there are many, just for reference:
The Mandalorian S1 Chapter 4
This is the first appearance of Cara Dune, she teams up with Mando in order to train and defend a village against raiders
IP Man 2
IP Man teaches some villagers how to defend themselves against mobsters
I believe it also happens in Goblin Slayer, the MC prepares a village to defend themselves against well... Goblins.
What's the first instance in science fiction or fantasy in which this plot was used?