We say "on your mind" to refer to what you are thinking about, and "in your brain" to refer to what you know, what you have learned. Why: it's common usage.
Regarding in or on the street, there is a difference in American and British usage. A Brit will say he lives in Maple Street to mean the same as what a Yankee means with he lives on Maple Street. We Americans use "in the street" as standing or lying in the roadway, perhaps because raised curbing on each side of many streets or roads creates a sense of containment. I don't know if the British use "in the street" the same way in this case.
There is overlapping meaning between "at the gym" and "in the gym." To say "in the gym" specifies actually inside the gym facility itself, while "at the gym" could also mean being around the premises -- say, just outside the door or in the parking lot or, perhaps but not necessarily always different, in the locker room after having finished a gym session. This overlap in which "at" comprises "in" plus some surroundings applies to almost any location: at the post office vs. in the post office, at the convention center vs. in the convention center. Note, however, that "at the hospital" conveys a different connotation from "in the hospital" (or, in British usage, "in hospital"). To be in the hospital indicates being a patient; at usually would not.
Student or Learner