The present paper aims to clarify the mechanism of infragravity wave (IGW) energy amplification over nearshore shoals reported in recent studies. Wave transformation and energy transfer between short waves (SWs) and IGWs were investigated using SWASH model for non‐breaking random waves propagating over trapezoid shoals with different bottom slopes. It was found that the time lag of IGWs relative to SW groups is the major mechanism for energy transfer from SWs to IGWs and the amplification of IGW energy over all segments of the shoal. The time lag is generated on the front slope and enlarged on the plateau of the shoal, decreases on the rear slope at the rate that is higher on milder slopes. Over the rear slope, the evolution of IGWs depends on the relative importance of de‐shoaling and nonlinear energy transfer. It was found that nonlinear energy transfer dominates over the rear slope gentler than 1/60, causing the IGW energy to increase over the first half of the de‐shoaling process and decrease over the second half whereas de‐shoaling dominates for larger rear slope and the IGW energy decay over the whole slope. It is demonstrated numerically and theoretically that the shoals with gentler bottom slopes amplify the IGW energy more effectively by providing longer distance for nonlinear energy transfer to build up. The persistent nonlinear energy transfer on the plateau indicates the important role of wave history in the IGWs evolution when SWs propagate over uneven bottoms. Strong free IGWs were detected on leeward of the shoal, possibly due to release of topography‐induced additional bound IGWs.