Inclusion Criteria:  Participant must have histologically or cytologically confirmed gastric (including gastroesophageal junction [GEJ]) or esophageal cancer (EC) that is locally advanced, unresectable, or metastatic, and not eligible for curative treatment Participant must have measurable disease according to Response Evaluation Criteria in Solid Tumors (RECIST) Version 1.1. If only 1 measurable lesion exists, it may be used for the screening biopsy if the baseline tumor assessment scans are performed greater than or equal to (>=) 7 days after the biopsy Participant must have Eastern Cooperative Oncology Group (ECOG) performance status 0 or 1  Gastric or GEJ Cancer Only - Must be refractory or ineligible to at least 2 prior lines of standard of care systemic therapy. Prior therapies must include fluoropyrimidine- and platinum-based chemotherapy. Participants with known human epidermal growth factor receptor (HER) 2 expression must have had HER2 targeting therapy as part of the prior therapy  Esophageal Cancer Only  - Must be refractory or intolerant to at least 1 prior line of systemic therapy. Prior therapies must include fluoropyrimidine-, and platinum-based chemotherapy (including chemoradiation therapy given as stage intravenous [IV] setting)  Exclusion Criteria:  Participant has an uncontrolled illness, including but not limited to the following: diabetes; ongoing or active bacterial infection (includes infection requiring treatment with antimicrobial therapy [participants will be required to complete antibiotics 1 week before enrollment]), symptomatic viral infection, or any other clinically significant infection; active bleeding diathesis and psychiatric illness/social situation that would limit compliance with study requirements Participant has received prior epidermal growth factor receptor (EGFR) or tyrosine-protein kinase mesenchymal-epithelial transition (cMet)-directed therapies Participant has had prior chemotherapy, targeted cancer therapy, immunotherapy, or treatment with an investigational anticancer agent within 2 weeks or 4 half-lives whichever is longer or had radiation therapy within 4 weeks before the first administration of study treatment. For agents with long half-lives, the maximum required time since last dose is 28 days. Toxicities from previous anticancer therapies should have resolved to baseline levels or to Grade 1 or less, (except for alopecia or post-radiation skin changes [any grade], Grade less than or equal to [<=] 2 peripheral neuropathy, and Grade <=2 hypothyroidism stable on hormone replacement) Participant has untreated brain metastases (a participant with definitively, locally treated metastases who is clinically stable, asymptomatic, and off corticosteroid treatment for at least 2 weeks prior to the first administration of study treatment is eligible), history of leptomeningeal disease or spinal cord compression that has not been treated definitively with surgery or radiation. If brain metastases are diagnosed on screening imaging, the participant may be rescreened for eligibility after definitive treatment Participant has a history of (non-infectious) interstitial lung disease (ILD)/pneumonitis that required steroids, or has current ILD/pneumonitis, or where suspected ILD/pneumonitis cannot be ruled out by imaging at screening. Esophageal cancer participants with history of completely resolved radiation pneumonitis (defined as radiographically stable for 3 months prior to enrollment without need of any treatment) may be enrolled