"on time" = at the right time
"in time" = before it was too late
I got to work on time this morning. I start work at 9:00 and I arrived at 9:00.
I got on the train in time, there's still 10 minutes left before it leaves.
Another one: just in time = just before it was too late; almost too late
It's okay, I ran the whole way and got on the train JUST in time, it leaves in one minute!
(just in time = almost too late)