you can say that the difference is in timing
when we use ف, there is a short period separating actions
for example جاء أحمد فعلي ... Ahmed came then Ali
The accurate meaning is that Ahmed came first and Ali was just behind him so they are not together but just behind each other
but ثم indicates that there is enough time between actions
for example جاء أحمد ثم علي .... Ahmed came then Ali
Ahmed arrived and may sat down, eat and talk then Ali came
that's it I hope I managed to enlighten you😊😊