DoorDash on Thursday announced it has agreed to buy Instacart in a $17 deal, combining the nation’s top grocery delivery app with a massive restaurant takeout service.