I never considered halflings to be without town guards or militias. Halflings are very much about their home communities and traditions and they would consider it a duty to fight to protect their towns. Rangers and rogues are obvious choices for scouting or strike teams but they also have their fighters and clerics and druids. This reverence for their community means that they are not expansionists and so don't typically form their own larger kingdoms or nations. As mentioned, they get along fine with good human communities and don't object to being nominally under the banner of a good lord, provided they are allowed a fair amount of autonomy within their own towns. They get the additional protection and trading partners and the lord can expand his reach without having to fight a bunch of halflings for it so it's a symbiotic relationship.

There are, of course, halflings who head out for the big city or become adventurers but those are a distinct rarity measured against the rest of halfling society.