The Sun has a mean diameter of 1.392×106 km and a distance of 1.496×108 km

The Moon has a mean diameter of 3,474 km and a distance of 384,400 km.

So the Moon is about 400 times smaller than the Sun (1.392×106 / 3,474) but coincidentally the Sun is 400 times further away. So they both look to be the same size. Which is why a total solar eclipse occurs.

Because the Moon is much closer to the Earth than the Sun is. The moon is only about 240,000 miles from Earth, while the Sun is an average of 93,000,000 miles away. Hold your thumb up to a large object, like a house, and walk away until the object is hidden by your thumb. Then start walking toward the object again and see what happens.