How far can the Sun and the Moon get? I noticed that last June the Sun was on the tropic of Cancer and moon on Madagascar:

Can you explain how that works and if they can get even farther in latitude?
The Earth's equator is inclined to the plane of the solar system (called the ecliptic) by 23 degrees. In other words, the Sun's position, as seen from the Earth, varies between 23 degrees North (at the northern hemisphere summer solstice) and 23 degrees South (at northern hemisphere winter solstice), appearing to cross the Earth's equator twice (at the equinoxes). 

The tropic lines mark the maximum apparent solar move north or south.

The Moon's orbit is inclined by about 5 degrees to the ecliptic so moves over a somewhat wider range of the sky as seen from the Earth. The Moon orbits the Earth every 28 days or so, so moves over that range each month.

At full Moon the Moon is opposite the Sun in the sky, so if the Sun was close to the tropic, then the Moon would be around the opposite tropic when full, and so on.