Context. Stellar activity and convection-related surface structures might cause bias in planet detection and characterization that use these transits. Surface convection simulations help to quantify the granulation signal. Aims. We used realistic three-dimensional (3D) radiative hydrodynamical (RHD) simulations from the Stagger grid and synthetic images computed with the radiative transfer code Optim3D to model the transits of three prototype planets: a hot Jupiter, a hot Neptune, and a terrestrial planet. Methods. We computed intensity maps from RHD simulations of the Sun and a K-dwarf star at different wavelength bands from optical to far-infrared that cover the range of several ground- and space-based telescopes which observe exoplanet transits. We modeled the transit using synthetic stellar-disk images obtained with a spherical-tile imaging method and emulated the temporal variation of the granulation intensity generating random images covering a granulation time-series of 13.3 h. We measured the contribution of the stellar granulation on the light curves during the planet transit. Results. We identified two types of granulation noise that act simultaneously during the planet transit: (i) the intrinsic change in the granulation pattern with timescale (e.g., 10 min for solar-type stars assumed in this work) is smaller than the usual planet transit (~hours as in our prototype cases); and (ii) the fact that the transiting planet occults isolated regions of the photosphere that differ in local surface brightness as a result of convective-related surface structures. First, we showed that our modeling approach returns granulation timescale fluctuations that are comparable with what has been observed for the Sun. Then, our statistical approach shows that the granulation pattern of solar and K-dwarf-type stars have a non-negligible effect of the light curve depth during the transit, and, consequentially on the determination of the planet transit parameters such as the planet radius (up to 0.90% and ~0.47% for terrestrial and gaseous planets, respectively). We also showed that larger (or smaller) orbital inclination angles with respect to values corresponding to transit at the stellar center display a shallower transit depth and longer ingress and egress times, but also granulation fluctuations that are correlated to the center-to-limb variation: they increase (or decrease) the value of the inclination, which amplifies the fluctuations. The granulation noise appears to be correlated among the different wavelength ranges either in the visible or in the infrared regions. Conclusions. The prospects for planet detection and characterization with transiting methods are excellent with access to large amounts of data for stars. The granulation has to be considered as an intrinsic uncertainty (as a result of stellar variability) on the precise measurements of exoplanet transits of planets. The full characterization of the granulation is essential for determining the degree of uncertainty on the planet parameters. In this context, the use of 3D RHD simulations is important to measure the convection-related fluctuations. This can be achieved by performing precise and continuous observations of stellar photometry and radial velocity, as we explained with RHD simulations, before, after, and during the transit periods.