There is no magic to learning prepositions. Unfortunately, they have to be memorized.
Remember, these are not phrasal verbs but general prepositions.
Also remember sometimes you can have two solutions.
e.g. on the train / in the train
I was on a boat last week.
I was in the car when you saw me.
Where you at the office last week?
Where you in the train? Were you on the train?