Asalamualikum sheikh, let's say i prayed maghreb behind imam but I joined at the 2nd rakat. Is the tashahud mandatory for me to recite when im following the imam during the 2nd rakat? What about when it comes to the 3rd rakat? Or can I remain silent?

Ustadh AbdulAziz al-Haqqan
When you catch the second rakah of Maghrib with the imam, you sit whenever he sits, following him. In the sitting that is the imam's first tashahhud, which is only your first rakah, it is not obligatory on you to recite the tashahhud, but if you do recite it there is no harm, so you may recite or stay silent. When the imam sits for the final tashahhud, that is your own tashahhud after two rakahs, so you recite it, then when he gives salam you stand and complete your remaining rakah and sit for your own final tashahhud, which is obligatory on you. Allah knows best.