Basic security in solar systems owned by the major factions is handled by police / patrol fighters and frigates. While they may seem low in numbers, attacking a police ship will automatically put a bounty on your head and will trigger a response from the nearest military base and ships if available.
Those ships will patrol a given sector for hostiles and smugglers. They will also come to the help to any ship endangered by a hostile. The side they'll choose to help will depend on the situation and the relation between the factions involved, they will always side with their own faction, then their allies, then to whoever got attacked first. If the fight gets out of hand, they will call the military for help if there's any in the sector.
Border sectors and large busy ones will often have a military base hosting dozens of fighters. Such bases act as the first line of defense against pirate raids and enemy incursions. They will also act as a police force when needed. raiding cargo ships when there's such a base in the vicinity won't be good for your health.
Each faction has its own military fleet (composed of the larger classes of ship) that is dispatched in the sectors under its control based on how much threat each sector is under. While most of the fleet will be at the borders, it's not uncommon to see such ships moving across quieter ones.
Policing not being their main job, depending on their current orders they may ignore calls for help from friendlies if they have something more important to do (for example, being engaged in a war). That said, it's still not advised to commit piracy acts just under their noses.