Here's the problem:
var svg = d3.select("body").append("svg")
.attr("width", 600)
.attr("height", 600)
.call(zoom)
.append("g");
You assign a group element instead of an svg element to a variable svg.
zoomapplies correctly to the svg element, but then when you call zoom.scaleTo(svg, 2), you zoom in on the group element, not the svg element.
, svg svg, .
var svg = d3.select("body").append("svg")
.attr("width", 600)
.attr("height", 600)
.call(zoom);
var mainContainer = svg.append("g");
JSFiddle: https://jsfiddle.net/skgktrcu/2/