I wanted to know like in a 4 rakat salat, if I forget to recite tashhud in 2nd rakat then what should be done? Or later i realise for eg in 3rd or 4th rakat that I haven't recited tashhud in 2nd rakat then what should I do? Should I leave it or do sajda e sahv?

If you realise before Ruku of 3rd rakat then you go back, recite it, continue the Namaz and do sajdah sahw at the end. If you remember after Ruku of 3rd rakat then continue the Namaz finish it and then do sajdah sahw.