It is often suggested that governments have police and armies primarily to protect the people. And, while there might be some motive of self-preservation involved, as a whole, the government functions as a selfless servant of the public. That is why it exists.
As popular as this dogma is, it remains deeply problematic. In fact, it can be seen to be profoundly mistaken when “the people” begin to defend their rights against the police and the armies—and then get beat up for doing so.
The owner of an aggressive pit-bull can talk all day long about how nice the dog is—until it gets irritated and bites you. In the same way, one can talk all day long about how benevolent governments are—for providing roads, and libraries, and bathrooms—until the riot gear comes out and citizens’ faces are getting smashed.
Make no mistake, there are plenty of well-meaning police officers and soldiers that, to the extent of genuinely dealing with aggression, do not fall under this general problem.
And there also is a sense in which the state does protect its subjects. But, this is only for the same reason a rancher protects its cattle and a farmer protects its crops: there is a harvest to be made. (Dead taxpayers aren’t very useful!) To whatever extent police and armies protect citizens, it is secondary to the primary purpose of self-preservation.