The online classifieds company Craigslist said that it had reached an agreement with 40 state attorneys general and agreed to tame its notoriously unruly “erotic services” listings. Prostitutes and sex-oriented businesses have long used that section of Craigslist to advertise their services.