How scientists calculated the weight of Mars to be 6.39 × 10^23 kg?
Yes, good point, and that technique is essential when we don't have a convenient orbiting body - as is the case when we're trying to determine the mass of Earth's moon.Also, the amount how much a focal point of the elliptical orbit of Mars around Sun deviates from the centerpoint of Sun could be one quantity that can be checked for consistency (after estimating the mass of Mars from the centripetal acceleration of Phobos and Deimos).
Well, not exactly. As long as the mass of the orbiting object is very small compared to the planet, you get a fairly accurate answer. But as the mass of the orbiting body increases, it becomes less accurate. For example, if you were to calculate the Earth's mass from just the Moon's orbital period and distance while ignoring the Moon's mass vs. doing so while accounting for the Moon's mass, you would get answers that differ by about 1%If you google for "calculate the mass of a planet" you'll find how this is done fairly quickly. I strongly suggest that you actually try the calculation - it is way more fun than just looking up the final answer.
If you do the math (just start with Newton's law of gravity) you'll find that the behavior of an orbiting object depends on the mass of the the object being orbited but not the mass of the orbiting object. This allows us to calculate the mass of Mars from the observed orbit of its moons, just as we canculate the mass of the sun from what we know of the Earth's orbit.