Afatinib targets and binds irreversibly to the tyrosine kinase domain of the EGFR and HER2 receptors. This binding prevents the activation of downstream signaling pathways, which are responsible for cell proliferation, survival, and migration. By inhibiting these pathways, afatinib effectively reduces tumor growth and induces cancer cell death.