We present lattice results for the form factors relevant in the K -> pion and D -> pion semileptonic decays, obtained from simulations with two flavors of dynamical twisted-mass fermions and pion masses as light as 260 MeV. For K -> pion decays we discuss the estimates of the main sources of systematic uncertainties, including the quenching of the strange quark, leading to our final result f+(0) = 0.9560 (57) (62). Combined with the latest experimental data, our value of f+(0) implies for the CKM matrix element |Vus| the value 0.2267 (5) (20) consistent with the first-row CKM unitarity. For D -> pion decays the application of Heavy Meson Chiral Perturbation Theory allows to extrapolate our results for both the scalar and the vector form factors at the physical point with quite good accuracy, obtaining a nice agreement with the experimental data. In particular at zero-momentum transfer we obtain f+(0) = 0.64 (5).