Can someone please explain to me how to solve this? I don't really understand how.

Step-by-step explanation:
If a point on a line is the midpoint, that means that the two segments created by the point are equal. In this case, XA = AY
We can set the two lengths equal to each-other.
[tex]3x = 5x - 12\\3x + 12 = 5x -12 + 12\\3x+12 = 5x\\2x = 12\\x =6[/tex]
Now that we know x = 6, we can solve for the lengths of each segment.
XA = 3x = 3(6) = 18
AY = 5x - 12 = 5(6) - 12 = 30 -12 = 18
XY = 3x + 5x - 12 = 8x - 12 = 8(6) - 12 = 48 - 12 = 36