  Mergers of binary compact objects, accompanied with electromagnetic (EM)
counterparts, offer excellent opportunities to explore varied cosmological
models, since gravitational waves (GWs) and EM counterparts always carry the
information of luminosity distance and redshift, respectively. $f(T)$ gravity,
which alters the background evolution and provides a friction term in the
propagation of GWs, can be tested by comparing the modified GW luminosity
distance with the EM luminosity distance. Considering the third-generation
gravitational-wave detectors, Einstein Telescope and two cosmic explorers, we
simulate a series of GW events of binary neutron stars and
neutron-star-black-hole binaries with EM counterparts. These simulations can be
used to constrain $f(T)$ gravity [especially the power-law model
$f(T)=T+\alpha(-T)^\beta$ in this work] and other cosmological parameters, such
as $\beta$ and the Hubble constant. In addition, combining simulations with
current observations of type Ia supernovae and baryon acoustic oscillations, we
obtain tighter limitations for $f(T)$ gravity. We find that the estimated
precision significantly improved when all three datasets are combined ($\Delta
\beta \sim 0.03$), compared to analyzing the current observations alone
($\Delta \beta \sim 0.3$). Simultaneously, the uncertainty of the Hubble
constant can be reduced to approximately $1\%$.
