Inclusion Criteria:  Patients with stage IV non-small cell lung cancer with disease progression on or up to 6 months from treatment with PD-1/PD- L1 inhibitor either alone or in combination with chemotherapy and/or anti-CTLA4 inhibitor; or patients with stage I-III non-small cell lung cancer with disease recurrence up to 6 months from receiving neoadjuvant/adjuvant/consolidation PD-1/PD-L1 inhibitor Measurable disease by Response Evaluation Criteria in Solid Tumors (RECIST) version (v) 1.1 Eastern Cooperative Oncology Group (ECOG) performance status 0-2 All immune-related adverse events (AEs) while receiving prior immunotherapy must have resolved to grade =< 1 prior to screening for the study. Patients with endocrine immune-related AE of =< grade 2 are permitted to enroll if they are stably maintained on appropriate replacement therapy  Female patients who:  Are postmenopausal for at least 1 year before the screening visit, OR Are surgically sterile, OR If they are women of childbearing potential (WOCBP), agree to practice 1 effective method of contraception and 1 additional effective (barrier) method, at the same time, and must agree to follow instructions for methods of contraception from the time of signing the informed consent, for the duration of treatment with nivolumab and 5 months after the last dose of nivolumab (ie 30 days [duration of ovulatory cycle] plus the time required for nivolumab to undergo approximately five half-lives), OR Agree to practice true abstinence, when this is in line with the preferred and usual lifestyle of the patient. (Periodic abstinence [e.g., calendar, ovulation, symptothermal, postovulation methods], withdrawal, spermicides only, and lactational amenorrhea are not acceptable methods of contraception. Female and male condoms should not be used together.) Agree not to donate egg(s) during the course of this study or within 5 months after the last dose of nivolumab (ie 30 days [duration of ovulatory cycle] plus the time required for nivolumab to undergo approximately five half-lives)  Male patients, even if surgically sterilized (i.e., status post-vasectomy), who:  Are sexually active with WOCBP must agree to follow instructions for method(s) of contraception for the duration of treatment with nivolumab and up to 7 months after the last dose of nivolumab (ie 90 days [duration of sperm turnover] plus the time required for nivolumab to undergo approximately five half-lives)., OR Agree to practice true abstinence, when this is in line with the preferred and usual lifestyle of the patient. (Periodic abstinence [e.g., calendar, ovulation, symptothermal, postovulation methods for the female partner], withdrawal, spermicides only, and lactational amenorrhea are not acceptable methods of contraception. Female and male condoms should not be used together) Agree not to donate sperm during the course of this study or within 120 days after receiving their last dose of study drug Absolute neutrophil count (ANC) >= 1.5 x 10^9/L without transfusion within 1 week preceding study drug administration Platelet count >= 100 x 10^9/L without transfusion within 1 week preceding study drug administration Hemoglobin >= 9 g/dL without transfusion within 1 week preceding study drug administration Total bilirubin =< 1.5 x upper limit of normal (ULN) Transaminases (aspartate aminotransferase/serum glutamic oxaloacetic transaminase-AST/SGOT and alanine aminotransferase/serum glutamic pyruvic transaminase-ALT/SGPT) =< 2.5 x ULN (=< 3 x ULN if liver metastases are present) Clearance >= 50 mL/min based either on Cockroft-Gault estimate or based on urine collection (12 or 24 hour) Glycosylated hemoglobin (HbA1c) < 7.0% Fasting serum glucose (=< 130 mg/dL) Fasting triglycerides =< 300 mg/dL Ability to swallow oral medications Voluntary written consent must be given before performance of any study related procedure not part of standard medical care, with the understanding that consent may be withdrawn by the patient at any time without prejudice to future medical care  Patients who have a history of brain metastasis are eligible for the study provided that all the following criteria are met:  Brain metastases which have been previously treated and/or are stable on most recent brain imaging Systemic corticosteroids at physiological doses, which are not to exceed 10mg/day of prednisone, or an equivalent corticosteroid  Exclusion Criteria:  Histology other than non-small cell lung cancer Central nervous system (CNS) metastasis that is symptomatic and uncontrolled Patients with spinal cord compression unless considered to have received definitive treatment for this and evidence of clinically stable disease for 28 days Presence of an EGFR, ALK, and ROS1 alteration Current systemic anti-cancer treatment other than the study agents, including other investigational agents Previous toxicity that led to permanent and indefinite discontinuation of prior immunotherapy Toxicity from prior immunotherapy required the use of additional immunosuppression other than corticosteroids for management of the AE Experienced recurrence of grade >= 3 immune-related AE if re-challenged with immunotherapy. Patients with endocrine immune-related AE of =< grade 2 are permitted to enroll if they are stably maintained on appropriate replacement therapy Interstitial lung disease that is symptomatic or may interfere with the detection or management of suspected drug-related pulmonary toxicity Known human immunodeficiency virus infection Known hepatitis B surface antigen-positive, or known or suspected active hepatitis C infection Any serious medical or psychiatric illness that could, in the investigator's opinion, potentially interfere with the completion of treatment according to this protocol Concurrent malignancy with evidence of residual disease. Patients with non-melanoma skin cancer or carcinoma in situ of any type are not excluded if they have undergone complete resection Breast feeding or pregnant women Previous treatment with PI3K, AKT, dual PI3K/mTOR inhibitors, TORC1/2 inhibitors or TORC1 inhibitors Current or prior use of immunosuppressive medication within 28 days before cycle 1 of study treatment, 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  Active or prior documented autoimmune disease within the past 2 years  NOTE: vitiligo, alopecia, chronic skin condition that does not require systemic therapy, psoriasis not requiring systemic treatment (within the past 2 years), and hypothyroidism (if stable on hormonal therapy) are not exclusion criteria Active or prior documented inflammatory bowel disease (e.g., Crohn's disease, ulcerative colitis) or pneumonitis Manifestations of malabsorption due to prior gastrointestinal (GI) surgery, GI disease, or for an unknown reason that may alter the absorption of sapanisertib. In addition, patients with enteric stomata are also excluded Resting electrocardiogram (ECG) indicating uncontrolled, potentially reversible cardiac conditions, as judged by the investigator (eg. unstable ischemia, uncontrolled symptomatic arrhythmia, congestive heart failure, corrected QT interval by Fredericia (QTcF) prolongation > 480 ms, electrolyte disturbances, etc.), or patients with congenital long QT syndrome or torsade de pointes  History of any of the following within the last 6 months before administration of the first dose of the drug:  Ischemic myocardial event, including angina requiring therapy and artery revascularization procedures Ischemic cerebrovascular event, including transient ischemic attack and artery revascularization procedures Requirement for inotropic support (excluding digoxin) or serious (uncontrolled) cardiac arrhythmia (including atrial flutter/fibrillation, ventricular fibrillation or ventricular tachycardia) Placement of a pacemaker for control of rhythm; New York Heart Association (NYHA) class III or IV heart failure Pulmonary embolism Major surgical procedure (as defined by the investigator) within 28 days prior to the first dose of study treatment and patients must have recovered from any effects of any major surgery. Note: Local surgery of isolated lesions for palliative intent is acceptable Uncontrolled illness including, but not limited to, ongoing or active infection, seizures, symptomatic congestive heart failure, uncontrolled hypertension, unstable angina pectoris, cardiac arrhythmia, pulmonary hypertension, uncontrolled asthma or oxygen (O2) saturation =< 90% by arterial blood gas analysis or pulse oximetry in room air, cardiac valve disease, active peptic ulcer disease or gastritis, active bleeding diatheses including any subject known to have evidence of acute or chronic hepatitis B, hepatitis C or human immunodeficiency virus (HIV), or psychiatric illness/social situations that would limit compliance with study requirements or compromise the ability of the subject to give written informed consent Poorly controlled diabetes mellitus defined as glycosylated hemoglobin (HbA1c) >= 7%; patients with a history of transient glucose intolerance due to corticosteroid administration may be enrolled in this study if all other inclusion/exclusion criteria are met Other clinically significant co-morbidities, such as uncontrolled pulmonary disease, active central nervous system disease, active infection, or any other condition that could compromise the patient's participation in the study Patients who are taking proton pump inhibitors (PPIs) within 7 days of the first dose of study drug or who require treatment with PPIs throughout the trial or those who are taking H2 receptor antagonists within 24 hours of the first dose of study drug Female subjects who are pregnant, breast-feeding or male or female patients of reproductive potential who are not employing two highly effective methods of birth control Any condition that, in the opinion of the investigator, would interfere with evaluation of study treatment or interpretation of patient safety or study results Known allergy or hypersensitivity to nivolumab, sapanisertib or any excipients  Any persistent toxicity National Cancer Institute (NCI) Common Terminology Criteria for Adverse Events (CTCAE) v5.0 grade >= 2 from previous anticancer therapy with the exception of alopecia, vitiligo, and the laboratory values defined in the inclusion criteria  Patients with grade >= 2 neuropathy will be evaluated on a case-by-case basis after consultation with the study physician Patients with irreversible toxicity not reasonably expected to be exacerbated by treatment with sapanisertib and/or nivolumab may be included at physician discretion