Suppose objects $X$ and $Y$ appear to be the same size. $X$ is actually of size $s_X$ and at distance $d_X$, and $Y$ is actually of size $s_Y$ and at distance $d_Y$. Then:
${s_X\over s_Y} = {d_X \over d_Y}$
or equivalently:
${d_X\over s_X} = {d_Y\over s_Y}$
Any three of these will determine the fourth.
For example, a U.S. quarter dollar coin is about 2.5 cm in diameter. Held at a distance of 275 cm, it appears to just cover the full moon. We can conclude that the distance to the moon, divided by the diameter of the moon, is equal to about 275 cm / 2.5 cm = 110.
If we somehow know that the distance to the moon is around 385,000 km, then this tells us that the diameter of the moon is around 3500 km, or vice versa, but we cannot get either one without the other.
Similarly, we know from the existence of total solar eclipses that
${d_☉\over s_☉} = {d_☾\over s_☾} $
where ☉ is the sun and ☾ is the moon. So we know that ${d_☉\over s_☉}\approx 110$ also. Again, if we know that the distance to the sun is about $150·10^6$ km, we can conclude that the sun's diameter is about $1.36·10^6$ km, and if we know the diameter of the sun instead we can estimate its distance. But without one we can't get the other.