In state courts, they are called District Attorneys, or if you live in Kentucky or Virginia, they are Commonwealth Attorneys. In federal courts, they are usually called US Attorneys. Basically, they prosecute crimes on behalf of their employers (the government). Government attorneys are the only ones who can do this, which you either have to be elected (state courts) or hired by the US Department of Justice (federal courts). They are lawyers, so you need to be licensed to practice law in the geographic area where you work, and some states require their district attorneys' to being practicing lawyers for a minimum amount of years before putting themselves for election (e.g., in Kentucky, you must be a practicing lawyer in Kentucky for at least 4 years before becoming a Commonwealth Attorney).