Inside our solar system, it's possible to get many direct measurements with probes. Since the planets are so close, it's also possible to observe them in great detail with various kinds of telescopes and monitor them over time.
Learning about planets in other solar systems is currently very difficult and we can mostly only learn about them indirectly at the moment. For example, when a very large planet, like the size of Jupiter of larger, which is orbitting very close to a star, like the orbit of Mercury or closer, we may notice a drop in brightness if the planet passes between us and the star. Once we know a planet is there and have some information about it from those observations, we can attempt to make other observations, such as attempting to get an actual image of the planet. If we're able to get an image of it, we can learn much more about it. When light passes through certain materials, it 'changes colour' in specific ways which we can compare against known 'colour changes' and figure out what's in the atmosphere. We may also be able to figure out the temperature because all matter gives off radiation based on how hot it is. That is why the sun is hot to us and gives us light, it's also one of the reasons we, and the earth, cool off over time; we're giving off low energy radiation; infra-red radiation. It may be possible to calculate the mass of the planet as well by precisely monitoring the star and corellating the star's movement according to the orbit of the planet around the star. Even our own star, even though it's MUCH larger than the planets, it is pulled by our gravity and moves a bit. We can detect this if our observations are precise enough. If we know the orbit of the planet, the mass of the star, and the amount the star moves due to the planet's gravity, we can solve for the mass of the planet.
There are many more ways, but, as you might expect, when there are thousands, tens of thousands of people trying to find ways to observe these objects, they come up with many tricks to do so.