[subject] + [verb] + 了 + [duration] + 了 [subject] + [verb] + 了 + [quantity] + [object] + 了
Two 了 in one sentence say an action has run for a stretch of time up to now, and usually is still running. The first 了 marks the stretch already done; the second says that is where things stand now.
The verb takes the first 了, then comes the duration, then the object, and the second 了 ends the sentence. English puts the duration last.
Drop the second 了 and the stretch is over.
English draws the same line with "studied" against "have been studying".
A quantity works in place of a duration, with the same sense of "so far". 已经 often goes in front of the verb.
A stretch of not doing something puts the duration first, then 没 and the verb. The verbal 了 drops, because 没 doesn't allow it; the final 了 stays, because the state still holds.