The progress in optical clock with uncertainty at a level of \(10^{-18}\) requires unprecedented precision in estimating the contribution of multipolar and higher-order effects of atom-field interactions. Previous theoretical and experimental results of dynamic multipolar polarizabilities and hyperpolarizabilities at the 813 nm magic wavelength of the Sr clock differ substantially. We employ the sum-over-states method to calculate dynamic multipolar polarizabilities and hyperpolarizabilities for the Sr and Mg clocks. Our differential dynamic hyperpolarizability at the magic wavelength of 813.4280(5) nm for the Sr clock is \(-2.09(43)\times10^{7}\) a.u., which agrees well with the recent theoretical and measurement results. Our differential multipolar polarizability of the Sr clock is \(2.68(94)\times 10^{-5}\) a.u., which is consistent with the theoretical work of Porsev {\em et al.} [Phys. Rev. Lett. 120, 063204 (2018)], but different from recent measurement of Ushijima {\em et al.} [Phys. Rev. Lett. 121, 263202 (2018)]. In addition, the lattice light shifts as the detuning and trap depth changed are studied in detail by using present multipolar polarizability and hyperpolarizability. It illustrates that for the Mg clock, there exists a distinctive operational lattice depth of \(5.3(1)E_R\) that allows the total light shift reduced to less than \(1\times 10^{-18}\) over the trap depth variation of \(4.1E_R<U<6.4E_R\).