DETROIT — General Motors Co. will buy AmeriCredit Corp. for $3.5 billion, a deal that allows the automaker to expand loans to customers with poor credit and offer more leases, key areas where GM must grow to accelerate its car sales. But the acquisition, announced Thursday, also means that GM, which is 61 percent owned by the U.S. government, is getting back into the business of making risky loans. AmeriCredit is an independent auto financing company that already works with about 4,000 GM dealers.