How did Eratosthenes know that the sun is far away?
The sun and the moon go around the observer once a day, Eratosthenes knew that the apparent size of moon doesn't change.  This must mean that Alexandria is near the centre of the moon's orbit.  But the apparent size also doesn't change when viewed from anywhere.  So everywhere is close to the centre of the moon's orbit.  Thus the moon must be much further than the radius of the Earth. If the moon were 6000 miles from the Earth, then it would seem to grow and shrink in size as it passed by (such an effect can be seen on Mars, where the moon really does orbit close to the planet)
And the Sun is further still. At half moon, the sun seems to be at $90^\circ$ to the moon.  This is only possible if the sun is much further away than the moon.
In conclusion, the distance to the sun must be very very large in comparison to the radius of the Earth, and we can assume that that the rays of light from the sun are parallel.