They both started out with x, the unknown amount of money.
David ended up with twice the original amount, which is 2x
Daniel had the original x plus $12 from his birthday. So he ended up with x+12.
Daniel and David ended up with equal amounts, so 2x = 12+x.
Subtract x from both sides. x=12.
Check:2x = 12+x
2*12 = 12 + 12 = 24.