Larry Krasner, a 56-year-old lawyer — who built a reputation in Philadelphia by suing the government and by defending activists and protesters — was sworn in Tuesday as the city’s district attorney, promising to bring sweeping changes to an office he described as “off the rails.”