Often it's because the constitution of their country states that a sitting President can't be brought up on charges - Mugabe is a very obvious example.
But don't worry, Yeltsin had Putin's back...
> President of Russia, ceased to carry out its mandate, has immunity. They can not be held criminally or administratively liable for acts committed by them during the execution of the President's powers
From https://www.journals.uchicago.edu/doi/abs/10.1086/688225
> Exile has been the second most common fate for dictators who lost office since World War II
See https://www.upf.edu/documents/2873379/2873034/Dictator_JOP_O... for a list of dictators and their destinations from 1946 to 2012