Charmed tetraquarks $T_{cc}=(ccbar{u}bar{d})$ and $T_{cs}=(csbar{u}bar{d})$ are studied through the S-wave meson-meson interactions, $D$-$D$, $bar{K}$-$D$, $D$-$D^{*}$ and $bar{K}$-$D^{*}$, on the basis of the (2+1)-flavor lattice QCD simulations with the pion mass $m_{pi} simeq $410, 570 and 700 MeV. For the charm quark, the relativistic heavy quark action is employed to treat its dynamics on the lattice. Using the HAL QCD method, we extract the S-wave potentials in lattice QCD simulations, from which the meson-meson scattering phase shifts are calculated. The phase shifts in the isospin triplet ($I$=1) channels indicate repulsive interactions, while those in the $I=0$ channels suggest attraction, growing as $m_{pi}$ decreases. This is particularly prominent in the $T_{cc} (J^P=1^+,I=0)$ channel, though neither bound state nor resonance are found in the range $m_{pi} =410-700$ MeV. We make a qualitative comparison of our results with the phenomenological diquark picture.