As a general rule, a double consonant after a vowel makes the vowel have a short sound. In this case, the double l after the "i" in "lilla" means the "i" becomes short. In "lila" it's a single l after the "i" and thus the "i" takes a long vowel sound.
There's a very good video on YouTube by AcademiaCervena regarding long and short vowel sounds. It's a complicated video, but I've seen it about three times and I still benefit from it every time I see it.
Hope this has helped mate, have a good one.
It's part of the process of turning a noun from the indefinite form into definite form. As mentioned in previous posts on this thread, Swedish has a property in which the noun in question is made definite "twice" in some sense. Whereas in English we would say "the little boy", in Swedish it's "den lille (or lilla) pojken", which, when translated directly, would be "the little the boy". This isn't necessarily something intuitive, so it's probably best to just accept this as the way that Swedish deals with definites.
By the way, the adjective that describes the noun must also be agreed, where the plural form of the adjective must be used.
For example, if you wanted to describe a house as large, you would say "ett stort hus" (stort being the adjective "stor" agreed in the ett- form). To make that sentence a definite, you'd then have to say "det stora huset", where "stort" has become the definite form "stora"
Hope this has cleared it up a little buddy.