I can't understand — how do they work differently? I mean, when 2 secs exposure is required for photographing milky way, while 30 mins exposure is needed for photographing star trails, why isn't the milky way visible on the 30 min?
The second question is clear, stars need some time to (apparently) move in the sky. The celestial sphere is rotating at 15 degrees/hour around poles (Polaris on North hemisphere) and the apparent movement is bigger near the celestial equator and smaller near celestial poles. But this movement is really a big problem if you want to take sharp photos of celestial objects, because ... they move! This effect is more pronounced with long lenses, and if you want to take a sharp photo of the Moon with a zoom lense you need to use speeds around 1/500.
The first question is more subtle to explain and I cant only imagine what could be happened. The Milky Way is a very dim object so using a long exposure may seem like a good idea, but the movement of the sky during that exposure time will produce a blurry image with a very dim light, almost invisible after enough exposure time. You have two options to avoid this problem: move the camera with precision to compensate the Earth movement (using a telescope automated tripod) or shooting with faster speed to freeze the movement on the photo, low f number to increase the amount of light that arrives to the sensor and use high ISO number to obtain more effect with this dim light.
Others have covered it but here is a short summary that MAY help.
For a given star in one position a short exposure is adequate.
For star trails
The required exposure for any given star at one point in the image is about the same BUT for the majority of the time a given star is not at a given point in the image. Exposure is a product of aperture and exposure period - so you will probably use a smaller aperture for star trails than for single exposures, but for a given brightness at a given point the total 'exposure' will be the same in each case.
Why? Read on ...
During the long exposure period, the earth rotates relative to the "fixed" star field - this motion is what creates the trails. While it is the earth which is* rotating relative to the stars it is common to say that 'the star field rotates' relative to the earth as it is how it appears to us and a convenient illusion to use.
As a "moving" star is in one area of the image for only part of the exposure, the time when the star is approximately at any one point in the image is small, so the actual star light at that point receives only a small part of the total exposure.
For any given point on the image, most of the time there is no star there (as they "move") so you get lots of background 'noise'.
The Milky Way IS in the star-trail image, but as all the objects in the Milky Way also "rotate" they all also leave trails and do not appear as individual objects.
- Very probably :-). One could argue that the world IS central to all reality and that all the universe moves relative to it AND the rules of physics allow this point of view, but the arithmetic gets horrendous and it doesn't make much sense to use this perspective.
2 seconds is quite a long exposure, but if you want to get more of the milky way, you might want to extend this to about 20 seconds. Look up the rule of 600 which should help you to find the right exposure time for your camera and lens. And yes when i have photographed the stars I shot in RAW and used the highest ISO setting (1600) and widest aperture of my lens f/3.5 but as others have commented you will get noise this way which can be improved by using image stacking, although I have yet to try it. Also I edit my photos using lightroom to recover the detail from the RAW files.