What should I do if I can only pass gas during Wudu and prayer due to stress, sometimes managing to hold it in, but other times unable to, causing the prayer time to pass?
Such medical condition has different degrees. If gas keeps on passing continuously with out holding period. In this case, you perform Wudhu for every Salah and pray even if gas passes during prayer.
if gas stops for a while enough to pray the obligatory Salah, then perform Wudhu and Salah during that gap even if you leave recommended acts of Salah just to keep your obligatory Salah with Wudhu.
Wassalam.