What you are trying to understand, is what we call in arabic "الام الشمسية و الام القمرية".
To define words in arabic we use "ال" which means "The"
Example: ولد : A boy الولد : The boy
There are two cases:
When the letter "ل" = "Laَm" is not spelt, we call it "الام الشمسية" = "Sun Laَm"
When it is spelt we call it "الام القمرية" "Moon Laَm"
So the question is when the letter "ل" is spelt and when it is not.
Rule 1: In arabic, the letter "ل" is not spelt when follwed by the these letters (Sun Letters) : ت, ث, د, ذ, ر,ز, س, ش, ص, ض, ط, ظ, ل,ن.
ُُExample : سيف (Sayfon) : A sword السيف (As-sayfu) : The sword
Important: Notice that the letter "ل" is not spelt but the letter "س" is spelt with emphasis, it is what we call in arabic "إدغام"
Rule 2: The letter "ل" is spelt when is it followed by these letters (Moon letters):
.أ, ب, ج, ح, خ, ع, غ, ف,ق, ك, م, ه,و,ي
Example: كتاب "Kitaَbon" : A book الكتاب "Al-Kitَbu" : The book
Important: Notice that the letter "ل" is spelt without using any vowel, and the the letter "ك" keeps its original sound
To better understand the concept you need to hear some examples.
I hope i have made myself clear
Good luck