short answer but correct.
The reason a sitting president may not be able to be prosecuted is due to the supremacy clause of the constitution which basically states no branch of gov't is supreme. One can't dominate them all. That is quite intentional to our democracy. Balance of power creates stability.
Of course, it has never really been tested. It is only legal opinion that the pres can't be prosecuted while in office, but the watergate prosecutors decided it was the more valid interpretation. There are other opinions.
As for your colonoscopy theory, not so much. A president can voluntarily transfer power to a vp if they will be unable to execute the powers of the office for a period of time. It is voluntary and they can undo it at will. The congress isn't involved other than to be notified.
The 25th amendmendment is an involuntary transfer of power from a president who has become unable to execute their duties. It requires signoff of the vp and a majority of the cabinet (roughly 8 people). It then requires certification by 2/3 of both houses. Not an easy bar to cross. Further, at any time, the president can petition congress to be reinstated. To deny the petition will again take a 2/3 vote of both houses. There is no limit to the number of times a removed pres can petition to come back.
The 25th was passed after kennedy was assasanated. Congress realized that if kennedy had lived, but in a coma, there would be a crisis of power. The vp couldn't act as president unless the president dies or was impeached. Being injured isn't really grounds for impeachment. So they created a trap door to transfer power to the vp until the pres either recovers or dies. They never expected it to be used in the case of insanity or they wouldn't have left it so open ended.
Which is why it's a perfect out for trump in his mind. He would technically still be the president, just without power or position.
Ryan would never be vp btw. He has way more power as speaker. He would take the presidency, but wouldn't accept the vp slot. It isn't automatic. A VP replacement still has to be nominated and confirmed. Succession is automatic, but someone can turn it down and it would go to the next in line.