The usage of in/on/at, like that of most prepositions, is metaphorically locative and, in the case of these three, dimensional.
The basic principles are simple:
in relates to a 3-dimensional container
on relates to a 2-dimensional surface
at relates to a 1-dimensional location |