Avalanche and Single-Photon Avalanche photodetectors (APDs and SPADs) rely on the probability of photogenerated carriers to trigger a multiplication process. Photon penetration depth plays a vital role in this process. In silicon APDs, a significant fraction of the short visible wavelengths is absorbed close to the device surface that is typically highly doped to serve as a contact. Most of the photogenerated carriers in this region can be lost by recombination, get slowly transported by diffusion, or multiplied with high excess noise. On the other hand, the extended penetration depth of near-infrared wavelengths requires thick semiconductors for efficient absorption. This diminishes the speed of the devices due to the long transit time in the thick absorption layer that is required for detecting most of these photons. Here, we demonstrate that it is possible to drive photons to a critical depth in a semiconductor film to maximize their gain-bandwidth performance and increase the absorption efficiency. This approach to engineering the penetration depth for different wavelengths in silicon is enabled by integrating photon-trapping nanoholes on the device surface. The penetration depth of short wavelengths such as 450 nm is increased from 0.25 µm to more than 0.62 µm. On the other hand, for a long-wavelength like 850 nm, the penetration depth is reduced from 18.3 µm to only 2.3 µm, decreasing the device transit time considerably. Such capabilities allow increasing the gain in APDs by almost 400× at 450 nm and by almost 9× at 850 nm. This engineering of the penetration depth in APDs would enable device designs requiring higher gain-bandwidth in emerging technologies such as Fluorescence Lifetime Microscopy (FLIM), Time-of-Flight Positron Emission Tomography (TOF-PET), quantum communications systems, and 3D imaging systems.