Exactly how Eratosthenes calculated the radius of the Earth has been lost. What is presently taught as his method is a simplified version described by Cleomedes.
It is unlikely that Eratosthenes assumed the Sun was infinitely distant, since he apparently also estimated the distance to the Sun himself. In any case, his work came after that of Aristarchus who wrote a huge treatise on the distance between the Earth and the Sun and Moon.
Aristarchus concluded that the Sun was much further away than the Moon (by about a factor 20), by claiming that the angle between the Earth, Moon and Sun, when the Moon was half-illuminated, was 87 degrees. He also knew from the angular size of the Moon and the curvature of the Earth's shadow during a lunar eclipse, that the Moon was a lot further away than the radius of the Earth.