Sounds like sleep apnea[1], which is usually discovered by a sleep partner, would be diagnosed with a sleep study, and can often be treated with a CPAP[2] machine, it keeps your airways open while you sleep, which helps you breathe.
[1] https://www.nhlbi.nih.gov/health/health-topics/topics/sleepa... [2] continuous positive airway pressure