For "the" Moon:
First, you need to know how big the Earth is. This is easily doable, using Eratosthenes' method - comparing the length of the shadow of a stick in Alexandria and Syene.
Then you can determine how massive the Earth is. Given its size, and the gravitational acceleration at the surface, you determine its mass.
Then, how big the Moon is. Well, during a Moon eclipse, assuming the Sun is very very far away, the diameter of the Earth's shadow is equal to the diameter of the Earth. So just look at the size and shape of the Earth's shadow on the Moon (a fraction of a circle) during an eclipse. Knowing the size of the Earth, it is easy to then determine the size of the Moon, by comparing the circle made by the Moon's circumference and the circle fragment made by Earth's shadow on it.
How far the Moon is? Once you know its size, just measure the angular diameter, do some basic trigonometry, and you get the distance.
Or you could do it the other way round, observing the Moon from two different places on Earth, knowing the distance between the places, and the angles the Moon makes with the horizon in both places. Then you could determine the Moon-Earth distance via trigonometry.
Alternatively, nowadays the Earth-Moon distance is measured very precisely by bouncing a laser off a reflector installed on the Moon, and tracking the reflection with a telescope and measuring the total propagation time.
How quickly do the Moon and Earth rotate around their common mass center? That's easy, just measure it by simple observation, just keep observing the sky and you'll figure it takes about 4 weeks.
At this point, you know how big are the Earth and the Moon, what is the distance between them, how heavy is the Earth, and how quickly they rotate around each other. The only unknown in the equation is Moon's mass, which is deduced via newtonian mechanics.
Having Moon's mass and its diameter, it is easy to determine the acceleration on its surface, again via Newton.
For other moons and planets:
It depends. The orbits of the planets were determined via many thousands of observations. Once you assume the Sun is in the middle and everything else runs around it, then all those many observations could only fit elliptical orbits of certain size and shape (this is not easy to explain intuitively, there's a lot of math). This was done before telescopes by Tycho Brahe and Kepler.
So, you know Venus' orbit, and Earth's. You do the math, and figure that at this moment, the distance between them is X. You look thought the telescope, and measure Venus' angular diameter to be 50 arcsec. Now do some basic trig, and you'll determine its diameter. Easy.
How heavy is Venus? Having no satellites, you can't tell. You need to wait for a comet to be deflected, or you need to send a space probe to orbit around it.
Or you could measure the tiny variations in Earth's orbit caused by Venus, and estimate Venus' mass that way. But this is not very precise.
Mars is easier, it has satellites already, so you can determine its mass. Same for Jupiter, Saturn, etc.