You can remain in Thailand until July 2026, as long as you don't get divorced. If you get divorced, you must leave Thailand as of the day the divorce is final. Your extension will be invalid that day.
Since you said you work remotely, you should be able to qualify for a DTV. This will require you to do a border bounce every 180 days, but you'll have a 5-year visa. You cannot get this from within Thailand though, so you'll need to go to a nearby country like Vietnam or Laos to apply there.
Just book a bus ticket out of Thailand, and then worry about your return ticket once you know. You can apply for your extension 30 days early at most immigration offices and 45 days early in Bangkok, Chiang Mai and Phuket. That should give you enough time to plan.
There's no requirement to have ANY amount of time on your passport to apply for a 1-year extension (not a renewal). If you don't have enough time on your passport for your extension, you'll just receive a short extension that's only valid until the expiration date of your passport.
There is no hospital that is or is not authorized to provide medical treatment and issue a certificate. There is no certificate.
You need them to provide you with a treatment plan, and you submit that for DTV. It's up to the embassy if they accept it or not. There's no authorization for any hospital to qualify for DTV.