If you forget to recite Tashahhud and stand up for the third Rak'at, then remember during your standing, you must sit down immediately on remembering that you forgot Tashahhud. You must recite Tashahhud then stand up for your third Rak'at.
'If you remember that in the forth Rak'at, you need to complete you SALAH till ASSALAMU Alaykum, and immediately recite Tashahhud then perform two Sajda of Sahw by prostrating and saying: Bismillah WABILLAH, ASSALAMU Alaina Ayyuhannabiyyu wa rahmatullah wabarakatuh. Then sit from your Sajda and do second Sajda saying the same, then sitting and reciting Tashahhud and Salam.
Wassalam.