Left and right edges become the bits in each symbol's code.
Edges become bit names
After the merges, each left edge contributes 0 and each right edge contributes 1.
left=0,right=1
A gets the shortest code
A is the most common symbol, and its code is 1.
The smaller counts get longer names
B uses 00, C uses 010, and D uses 011.
B=00,C=010,D=011
Summary
No code is the prefix of another code, so the receiver can read the bitstream from left to right.
prefix code