The Juno spacecraft has measured Jupiter's gravitational field to an unprecedented precision. These data suggest that Jupiter could have a diluted (low mean-density) core over 40% of its radius. Despite the large mass (an order of magnitude larger than that of the Earth) of heavy elements (other than hydrogen and helium) in the core, its spatial spread poses a challenge to the conventional Jupiter formation model based on the assumption of runaway gas accretion onto a distinct heavy-element core. While Jupiter's original rocky/metallic core could have been subsequently eroded by its surrounding convective gaseous envelope, it is unlikely for most of its mass to have diffused over such an extended region during the past 4.56 Gyr. With a series of 3D hydrodynamic simulations, we show that sufficiently energetic collisions between additional planetary embryos and the newly emerged Jupiter can shatter its primordial heavy-element compact core and mix the heavy elements with the outer envelope. This leads to an internal structure consistent with the diluted core scenario which is also found to persist over billions of years. A similar event may have also occurred for Saturn. We suggest that different mass and speed of the intruding embryo may have contributed to the structural dichotomy between Jupiter and Saturn.