There are various possibilities but I don't see the run of the mill of what you find in a town to be especially challenging in a fight. For the main town in the area I'm running now basically there are a couple of types:
Town Watch: These are just basically ordinary citizens deputized to keep an eye on things, enforce basic regulations, watch for fires, and keep order. They don't really have much combat ability and they'll just raise an alarm if anything serious comes up. Their stats are basically human rabble with a badge and armed with a truncheon (club). They aren't any kind of threat in and of themselves but if PCs mess with them then there will be serious trouble with the authorities.
Town Guards: These are basic trained soldiers who garrison the town gates, watch towers, etc. They are level 5 soldier minions equipped with a halberd. They will fight if attacked, are usually found in a group of 3-5 and often backed up by a Human Guard who acts as a sergeant. They still aren't a really serious threat on their own but the garrison can always call on a few higher level figures or larger numbers if necessary. If the town watch needs reinforcement to handle a problem then some of these guys will show up.
Unique Figures: The above are just the standard figures that provide background. Specific named individual guards etc are custom stat blocks as appropriate. So if a particular guard figures in an adventure where he needs to be fleshed out then he would be whatever level and type is appropriate. If there are specific problems then the authorities bring in knights, wizards, clerics, whatever they need to make the problem go away. The inhabitants of the town aren't generally going to be able to deal with higher level monsters, rampaging high level PCs, etc. by main force. If they have a problem like that then they'll need heroes to help them out or else things will go bad for them.
Nice! The visual I just had was Stormtroopers vs Bounty Hunters. At some point, the Empire had enough of Han Solo's . . .antics, and they had to hire out for some specialized muscle. And it worked.
The run of the mill town guard can be mowed down like stormtroopers, but once someone with some authority learns of the PC's actions, then they will start to see some real resistance, and possibly named adversaries tailored to the PC's and with good intel about their abilities.
So for some rules-side advice, normal guards should be minions of the party's level or even lower, with maybe one 'captain' or 'sargeant' that is a soldier of the party's level. A non-fight, basically, to show just how much juice the party has. After that, SWAT teams and hit squads of the medival variety can show up as encounters befitting the party, L+1 or so. If they are still slaughtering the defenders of the crown, they might run into a mercenary group or an elite trained crew, in an ambush or assassination attempt that is truly tough at L+4 or 5.
As for roles, I'd follow good encounter building design and avoid making a troop of guards all soldiers. Just like an entire party of martial characters can have a varied playstyle and combat technique, the guards likely have different specialties. You might have a burly guy that swings his axe in big arcs, or a noble that trained with a rapier to deflect most hits. All in the same uniform, but different underneath.
Jay