Salatul Ehtiyat is obligatory when a valid repairable doubt occurs during performing a Prayer of 4 Rak'ats after completing the Prayer. It can be one or two Rak'ats depending on the number of Rak'ats which were involved in the doubt.
1. Doubt between 2nd and 3rd Rak'ats after starting the second Sajda of the second Rak'at: Take it as 3rd Rak'at and pray one Rak'at of Salatul Ehtiyat.
2. Doubt between 3rd or 4th Rak'ats: Take it as 4th Rak'ats and pray two Rak'ats of Salatul Ehtiyat of sitting position or one of standing position.
3. Doubt between 2nd or 4th Rak'ats: take it as the fourth Rak'at and pray two Rak'ats of standing of Salatul Ehtiyat.
4. Doubt between 2nd or 3rd or 4th Rak'at: take it as 4th and pray two Rak'ats of standing and two Rak'ats of sitting of Salatul Ehtiyat.
It is recommended to thing properly when you doubt trying to reach to a clear picture. If the doubt remains 50 to 50 then rules of Doubt apply.
Any doubt between first and second or first and second or third or first and any other Rak'at invalidates the Salaah. Any doubt in Morning or Maghrib Prayer invalidates the Prayer.