If some people come in the mosque after the jamah of the mosque is over and they establish second jamah then you should not join them by breaking your salah rather complete your salah. Likewise if you have offered fardh salah alone then do not join them in jamah with nafl intention. However if you are offering fardh salah alone and the jamah of the mosque starts then you may join the jamah of the mosque by breaking your salah provided you have not completed one rakah of two rakah salah and three rakahs of the four rakah salah. Likewise if you have completed fardh salah alone then you may join the imam in Zuhr and Isha salah with nafl intention. So is mentioned in the books of Fiqh and Fatawa.
Allah knows Best!
Darul Uloom Deoband