Writing Korean rules for ㄹ and vowels

Is there a rule when or if a consonant is placed after a vowel and a standalone vowel follows in comparison to putting the consonant or double consonant in the new syllable. I guess the question is very difficult and theoretical so let me give some examples

Saram people 사람 why does the ㄹ not follow 사
Dokil Germany 독일 why not 도 길
Dolaoda to return on the other hand has ㄹ below the vowel 돌아오다 instead of 도 라오다

To study Korean is written 한국어를공부하다 why not 얼 을

Thanks 가사합니다

These sort of rules are not something I’ve put much effort into learning. But as no one else has answered this is my take on it.

Disclaimer: not a naitive. If anything below is incorrect please correct me.

I think this question might have to divided due to word origin.

For Sino-Korean words every character has a corresponding Chinese character behind it. Looking at your last example is probably the easiest. 한국어를 can be written as 韓國語를. Combining the object particle with the Hangul representation of the Hanja is not possible. Furthermore, each Hanja has one or more Hangul representation. Apart from those, other Hangul combinations are not used. An example related to your example 사람 is 살인 (not 사린). The Chinese character 人 is written 인 with Hangul which means 사람.

For native words, the ㄹ always seem to be pushed to the first position in the next block in these situations. Looking at the etymology for 사람 I believe it would have been written 살암 if not some kind of rule denied that.