Candy giant Mars said on Wednesday it would buy Cheez-It and Pringles maker Kellanova in a nearly $36 billion deal.