The move by dozens of states to restrict what their residents can buy with the food assistance program’s benefits follows years of petitioning the federal government.