Testing the Addition of an Anti-cancer Drug, Berzosertib (M6620, VX-970), to the Usual Treatments (Carboplatin and Gemcitabine) and to Pembrolizumab for Patients With Advanced Squamous Cell Non-small Cell Lung Cancer

This phase Ib/II trial studies the best dose of carboplatin when given together with berzosertib, gemcitabine and pembrolizumab and to see how well it works in treating patients with stage IV squamous cell non-small cell lung cancer that has spared to other placed in the body (advanced). Berzosertib may stop the growth of tumor cells by blocking some of the enzymes needed for cell growth. Chemotherapy drugs, such as carboplatin and gemcitabine, work in different ways to stop the growth of tumor cells, either by killing the cells, by stopping them from dividing, or by stopping them from spreading. Immunotherapy with monoclonal antibodies, such as pembrolizumab, may help the body's immune system attack the cancer, and may interfere with the ability of tumor cells to grow and spread. Giving berzosertib together with carboplatin, gemcitabine, and pembrolizumab may work better in treating patients with squamous cell non-small cell lung cancer compared to carboplatin, gemcitabine, and pembrolizumab alone.

PRIMARY OBJECTIVES:

I. To determine the recommended phase 2 dose (RP2D) of carboplatin in combination with berzosertib (M6620) and gemcitabine/pembrolizumab, in patients with squamous cell non-small cell lung cancer (Sq-NSCLC). (Lead-in Phase 1B) II. To compare progression-free survival (PFS) of carboplatin/gemcitabine/pembrolizumab with and without berzosertib (M6620, VX-970) in patients with Sq-NSCLC, as measured by a hazard ratio in an intent-to-treat analysis. (Phase 2)

SECONDARY OBJECTIVES:

I. To compare progression-free survival (PFS) of carboplatin/gemcitabine/pembrolizumab with and without berzosertib (M6620, VX-970) in patients with Sq-NSCLC, as measured by a hazard ratio in an as-treated analysis.

II. To compare PFS of carboplatin/gemcitabine/pembrolizumab with and without berzosertib (M6620, VX-970) in patients with ataxia telangiectasia mutated (ATM)-deficient Sq-NSCLC, as measured by a hazard ratio.

III. To compare overall survival (OS) and overall response rate (ORR) of carboplatin/gemcitabine/pembrolizumab with and without berzosertib (M6620, VX-970), in patients with chemotherapy-naive Sq-NSCLC.

IV. To determine the systemic drug exposure of berzosertib (M6620, VX-970) and gemcitabine, as correlates of efficacy and toxicity.

V. To determine the safety and tolerability of berzosertib (M6620, VX-970) in combination with carboplatin/gemcitabine/pembrolizumab.

VI. To observe and record anti-tumor activity.

EXPLORATORY OBJECTIVES:

I. To identify molecular subpopulations of patients who have increased sensitivity to the berzosertib (M6620, VX-970)/carboplatin/gemcitabine/pembrolizumab combination.

II. To explore the prognostic and predictive qualities of the ATM immunohistochemistry (IHC) assay for clinical response and PFS.

III. To explore inflammation-associated gene signatures and clinical response.

OUTLINE: This is a phase Ib, dose de-escalation study of carboplatin followed by a phase II study. Patients are randomized to 1 of 2 arms.

ARM A: Patients receive pembrolizumab intravenously (IV) over 30 minutes on day 1, gemcitabine hydrochloride IV over 30 minutes on days 1 and 8, carboplatin IV over 30 minutes on day 1, and berzosertib IV over 60 minutes on days 2 and 9. Treatment repeats every 21 days for up to 4 cycles in the absence of disease progression or unacceptable toxicity. Patients then receive pembrolizumab IV over 30 minutes on day 1 and berzosertib IV over 60 minutes on days 2 and 9. Cycles repeat every 21 days for up to 9 months in the absence of disease progression or unacceptable toxicity. Patients then receive pembrolizumab alone IV over 30 minutes on day 1. Cycles repeat every 6 weeks for up to 1 more year in the absence of disease progression or unacceptable toxicity. Patients undergo magnetic resonance imaging (MRI) scans and/or computed tomography (CT) scans, and undergo blood specimen collection on study.

ARM B: Patients receive pembrolizumab, gemcitabine hydrochloride, and carboplatin as in Arm A. Patients undergo MRI scans and/or CT scans, and undergo blood specimen collection on study.

After completion of study treatment, patients are followed up every 3 months for 12 months.

Eligibility Criteria:
Inclusion Criteria:

* Patients must have histologically confirmed NSCLC of predominantly squamous cell histology, stage IV (American Joint Committee on Cancer \[AJCC\] 8th edition)
* Patients must have measurable disease, as defined by Response Evaluation Criteria in Solid Tumors (RECIST) version (v)1.1
* Patients must have tumor tissue available at time of enrollment, or be willing to undergo a biopsy for integrated biomarker studies
* Patients with a history of prior platinum-based systemic chemotherapy given as neoadjuvant, adjuvant, or consolidation therapy for early stage or loco-regionally advanced NSCLC are eligible, if therapy is completed one year prior to initiation of treatment. Patients must not have had prior systemic chemotherapy or immunotherapy for metastatic disease
* Patients with prior immunotherapy given as neoadjuvant, adjuvant, or consolidation therapy for early stage or loco-regionally advanced disease are eligible, if treatment is completed one year prior to initiation of treatment
* Patients must have Eastern Cooperative Oncology Group (ECOG) performance status of 0-1 (Karnofsky \> 60%)
* Age \>= 18 years. Because no dosing or adverse event data are currently available on the use of these drug combinations in patients \< 18 years of age, children are excluded from this study, but will be eligible for future pediatric trials
* Leukocytes \>= 3,000/mcL
* Absolute neutrophil count \> lower limit of normal (LLN)
* Platelets \> LLN
* Total bilirubin =\< institutional upper limit of normal (ULN)
* Aspartate aminotransferase (AST) (serum glutamic-oxaloacetic transaminase \[SGOT\])/alanine aminotransferase (ALT) (serum glutamate pyruvate transaminase \[SGPT\]) =\< 3 x institutional ULN
* Creatinine =\< institutional ULN OR glomerular filtration rate (GFR) \>= 60 mL/min/1.73 m\^2 unless data exists supporting safe use at lower kidney function values, no lower than 30 mL/min/1.73 m\^2
* Patients with human immunodeficiency virus (HIV) infection are eligible if they are on effective anti-retroviral therapy with undetectable viral load within 6 months, provided there is no expected drug-drug interaction
* Patients with evidence of chronic hepatitis B virus (HBV) infection are eligible if the HBV viral load is undetectable on suppressive therapy (if indicated), provided there is no expected drug-drug interaction
* Patients with a history of hepatitis C virus (HCV) infection are eligible if they have been treated and cured. For patients with HCV infection who are currently on treatment, they are eligible if they have an undetectable HCV viral load
* Patients with treated brain metastases are eligible if clinically stable, i.e., on stable doses of anti-convulsant therapy and/or stable doses of corticosteroids which are not to exceed 10 mg/day of prednisone, or an equivalent corticosteroid
* Patients with a prior or concurrent malignancy whose natural history or treatment does not have the potential to interfere with the safety or efficacy assessment of the investigational regimen are eligible for this trial
* Patients with known history or current symptoms of cardiac disease, or history of treatment with cardiotoxic agents, should have a clinical risk assessment of cardiac function using the New York Heart Association Functional Classification. To be eligible for this trial, patients should be class 2B or better
* Patients must be willing to comply with birth control requirements: The effects of the agents in this study (or similar agents) on the developing human fetus are either unknown, or known to be teratogenic, embryotoxic, and fetotoxic in mice and rabbits. For this reason, women of child-bearing potential and men must agree to use adequate contraception (hormonal or barrier method of birth control; abstinence) prior to study entry, for the duration of study participation, and for 6 months after completing treatment administration. Should a woman become pregnant or suspect she is pregnant while she or her partner is participating in this study, she should inform her treating physician immediately. Men treated or enrolled on this protocol must also agree to avoid donating sperm for during the study period, and to use adequate contraception prior to the study, for the duration of study participation, and for 6 months after completion completing treatment administration
* Patients must have the ability to understand and willingness to sign a written informed consent document. Participants with impaired decision-making capacity who have a legally-authorized representative and/or family member available will also be eligible

Exclusion Criteria:

* Patients with severe intercurrent illness or comorbidity are not eligible
* Patients with contraindications to immunotherapy (e.g., solid organ transplant or active autoimmune disease requiring immunosuppressant therapy within 2 years of enrollment) are not eligible
* Patients with prior systemic chemotherapy for metastatic disease are not eligible
* Patients who are receiving any other investigational agents are not eligible
* Patients with a history of allergic reactions attributed to compounds of similar chemical or biologic composition to berzosertib (M6620, VX-970), pembrolizumab, gemcitabine, carboplatin, or other agents used in study are not eligible
* Patients with severe bone marrow depression or significant bleeding are not eligible
* Patients with psychiatric illness/social situations that would limit compliance with study requirements are not eligible
* Berzosertib (M6620, VX-970) is primarily metabolized by CYP3A4; therefore, concomitant administration with strong inhibitors of CYP3A4 (e.g. clarithromycin, itraconazole, ketoconazole, HCV and HIV protease inhibitors, nefazodone, posaconazole, telithromycin, voriconazole) or strong inducers of CYP3A4 (e.g. carbamazepine, rifampin, phenobarbital, phenytoin, St. John's wort) should be avoided. Because the lists of these agents are constantly changing, it is important to regularly consult a frequently-updated medical reference. As part of the enrollment/informed consent procedures, the patient will be counseled on the risk of interactions with other agents, and what to do if new medications need to be prescribed or if the patient is considering a new over-the-counter medicine or herbal product
* Pregnant women are excluded from this study because the agents in this study may have the potential for teratogenic or abortifacient effects. Because there is an unknown but potential risk for adverse events in nursing infants secondary to treatment of the mother with the study agents, breastfeeding should be discontinued if the mother is treated with the study agents berzosertib (M6620, VX-970), pembrolizumab, gemcitabine, or carboplatin
* Berzosertib (M6620, VX-970) should be used with caution in patients with clinical evidence of germline defects in their deoxyribonucleic acid (DNA) damage repair pathway (for example, patients with Li-Fraumeni syndrome or ataxia telangiectasia) due to a possible increase in the toxicity of DNA-damaging agents when paired with berzosertib (M6620, VX-970)
* Patients must not have received or be scheduled to receive radiation therapy within 7 days or less from gemcitabine administration
* Current or prior use of immunosuppressive medication within 28 days before the first dose of pembrolizumab, with the exceptions of intranasal and inhaled corticosteroids or systemic corticosteroids at physiological doses, which are not to exceed 10 mg/day of prednisone, or an equivalent corticosteroid
* Patients must not have received an allogeneic stem cell transplant
* Patients must not have active, uncontrolled infections or recently received active vaccinations