Consider, for a moment, pointing your camera at a wall that's completely even lit. Let's assume you start with a 50 mm lens with a 25 mm aperture (i.e., f/2). If you change to a 100 mm lens you're reducing the angle of view so you're collecting light from a smaller area -- so you're collecting less light. To be more specific, you're cutting the angle of view in half, which reduces the area to 1/4th as much, so you're collecting 1/4th as much light. To look at it from a slightly different viewpoint, the light from a given part of the input gets spread over quadruple the area on the sensor/film, so it only appears 1/4th as bright on any given part of the sensor/film.
Using a relatively aperture compensates for that so, for example, f/2 gives the same total amount of light entering the camera regardless of the combination of focal length and aperture size necessary to get to f/2.
Most astrophotography is a bit different though. In particular, when you're taking a picture of a star, doubling the focal length should not double the apparent size of the star. Other than the sun, all the stars1 are far enough way that they should always show up as a point source. Doubling the focal length does not mean the star will be projected onto four times the area on the film/sensor. Rather the contrary, with the limits of sharpness of the optics, any focal length you use will still project the stars image as a point source.
I say "most" above, because this really applies only to stars. For the moon, nebulae, comets, and closer planets, you're typically magnifying to the point that the object in question projects as a disc on the sensor/film. As soon as that happens, you get back to the situation originally described: changing the focal length changes the apparent size of the object. A long focal length spreads the same light over more pixels, so you need to collect more light to compensate.
¹ Purely as a technicality, a few of the very largest telescopes theoretically have enough resolution to actually resolve a disc of a couple of extremely large, relatively nearby stars such as Betelgeuse. Even with them, this is still purely theoretical though -- the atmosphere is never still enough for them to achieve the necessary level of detail.
If a 200 inch telescope were placed in orbit, outside the atmosphere, then we could actually see Betelgeuse as a disc rather than a point source. Even that's only possible because Betelgeuse is almost astoundingly huge and relatively nearby though. For most stars you'd need an orbiting telescope that was much larger still.