Before they gave marbles away H=B where H and B are the numbers of marbles each has.
The situation now is Homer has H+30 and Bart has B+6.
The ratio is (B+6)/(H+30)=7/5. But we know B=H, so:
(H+6)/(H+30)=7/5. Cross-multiply: 5H+30=7H+210.
But: 2H=-180 so H=B=-90! This is clearly nonsense.
Let’s reverse the giveaways:
(B+30)/(H+6)=(H+30)/(H+6)=7/5, 5H+150=7H+42, 108=2H so H=B=54 and they currently have H=60 and B=84.
This is a sensible answer and may be the intended answer: Bart gave away 30 marbles and Homer gave away 6.