use of 在 with verbs that imply position or location
I'll address your last statement first since it is the quickest. when 在 comes directly before the verb it is known as the durative aspect marker (durative as in &quot;duration&quot;). In this case its function is identical to the role of &quot;-ing&quot; in English, it shows that the action is undergoing and has yet to be completed.
As for the other use case; when 在 isn't functioning as the durative aspect marker its function is that of a coverb (see my description of a coverb here), the direct English equivalent in this case would be &quot;in&quot; or &quot;at&quot;. When used in this way 在 must be followed by  a noun, the combination of 在 + the noun forms an adverbial phrase (for instance, 在北京 from your first example). Whether this adverbial phrase is placed before the verb or after the verb is dependent on what type of verb it is.
One type of verb is a &quot;displacement&quot; verb, meaning a verb that results in something being displaced. 跳 (to jump) is an example of this, the action of jumping results in you being displaced. In the case of displacement verbs, the adverbial phrase containing 在 can come before or after the verb. The caveat is that placing it before the verb means that is the location prior to being displaced while placing it after the verb means that is the location after being displaced. Take for example, &quot;我跳在桌子上&quot; and &quot;我在桌子上跳&quot;. The first implies that you jumped onto the surface of the table while the latter implies that you were on the surface of the table prior to jumping.
Another type of verb is a &quot;stative&quot; verb, a verb that describes a state. This includes 坐 (to sit), 睡觉 (to sleep), and also 住 (to live) from your example. These are all verbs (action words) by definition but ironically aren't done actively. You do not actively sit, or actively live. You do it passively, with no effort or thought on your part. In cases such as these the adverbial phrase containing 在 can come before or after the verb without altering the sentence in any meaningful way. Where you chose to sit your bum and where you are as a result of sitting down are one in the same, no meaningful difference.
I can't think of a name for the rest of the verbs, but in all other cases the adverbial phrase containing 在 should come before the verb. Such is true for 学 (to learn)， 教 (to teach), 吃 (to eat), etc. You can only say where you were when you began doing these actions, you cannot say where you are as a result of doing the action, so always place the locative phrase before.
One thing of note is that verbs such as 去 (to go), 飞 (to fly), etc. all belong to the last category. You might be duped into believing that they belong to the first (the displacement verbs), but that category is reserved for movement within your immediate area. You can jump to a position relative to your self, be shoved to a position relative to yourself, etc. and these are all acceptable uses of 在, but when you are talking about flying to a distant place or other such actions you cannot use 在 for connecting the destination with the verb, you must use 到 (to) instead