Because the two triangles are similar, one is a scaled down version of the other.
You can figure out that scale by comparing two matching sides, in this case AD and AB.
AD = 2 and AB = 2+4 = 6
So 2/6 = 1/3, telling us each side of the smaller triangle is 1/3 the size of the original.
Now we need to find ED and know CB = 12. Knowing ED = 1/3 of CB:
ED = 1/3 • 12 = 4