While an aircraft is airborne, the local barometric pressure can change, causing an altimeter to no longer display the correct altitude. How are altimeters re-calibrated to display the correct altitude, or there are other methods to accomplish that?
Altimeters are calibrated to a standard atmosphere model (International Standard Atmosphere, ISA).
What the altimeter shows you is the vertical distance between the altitude equivalent to your current pressure (pressure altitude) and a reference "pressure altitude". The reference pressure altitude is set in pressure units (hPa or In. Hg) on the altimeter subscale. This is known as the "altimeter setting", set in the "altimeter setting window".
Image credit: FAA Pilots Handbook of Aeronautical Knowledge
Flying at lower altitudes (below "transition altitude"), the altimeter is set to airport/regional QNH, which is a pressure calculated so that if you were standing on the measurement point, the altimeter would indicate your exact elevation. At other altitudes, it would approximate altitude above mean sea level, although it would show incorrectly if temperature differed from ISA.
Above transition altitude, the altimeter is set to QNE, or standard pressure (1013.25 hPa, or 29.92 In. Hg). The altimeter will now only indicate correctly if both temperature and pressure are in accordance with ISA. You are now flying on "flight level" (where the FL is your QNE indication in hundreds of feet, ie 20,000 ft = FL200).
For the purpose of avoiding obstacles, both QNH and QNE have to be corrected using various methods, which are described in various manuals. (QNH for temperature, QNE for both temperature and pressure, both for other possible factors such as wind etc). For instance, this diagram shows three different aircraft, all flying the same pressure altitude, but with three different true altitudes:
Image credit: FAA Pilots Handbook of Aeronautical Knowledge
However, altitude is also used for the purpose of traffic separation, and for this purpose, neither QNH or QNE is corrected. This might sound counter-intuitive, but as long as your altimeter is showing the same error as any conflicting traffic, you can be safely separated, therefore: The altitude shown on the altimeter is not corrected at all (except by calibration for possible aerodynamic interference, such as compressibility, venturi-effects etc).
In technically sophisticated aircraft, barometric altitude input is used for vertical navigation. Since vertical navigation is concerned with the true altitude of the aircraft, the aircrafts Air Data Computer (ADC) will calculated a true altitude based on information available to it (either through sensors, or through pilot input). The true altitude is however, as stated, not shown on the pilots primary flight instruments.
There are two separate answers to this question, depending on what altitude the flight is conducted.
At lower altitudes, below the transition altitude (18,000' in the US, but it varies from country to country), it is the responsibility of the pilot to receive the local "altimeter setting" -- which is the local barometric pressure, corrected to sea level. So if you are preparing to takeoff from an airport on the high pressure side of the front, that might be 30.30 inches of mercury, and this value would be set in the altimeter, and at this point the altimeter should display the field elevation for where you are.
Now let's say that you fly across the front into an area of much lower barometric pressure -- perhaps 29.80" Hg. That is now what is set into the altimeter, and upon landing your altimeter will display the altitude of the airport where you've landed.
Note that if you did this all at once, going from 30.30 to 29.80, you'd be dialing in a very large change into your altimeter, which would change the indicated altitude by about 500 feet, meaning that you were that far off of the altitude you thought you were flying, and that's a bad thing. So what happens in reality is that every few dozen miles, you'd get an updated altimeter setting from any of the various weather reporting facilities available -- ATC, automated ASOS broadcasts, data-linked weather, FSS, etc. So you'd adjust from 30.30 to 30.25, then later to 30.31, then later to whatever the next station was reporting, and so on -- each a much smaller adjustment.
For aircraft flying at high altitudes (and high groundspeeds), this process becomes impractical, so a different solution is used. Passing through the transition altitude, a standard setting of 29.92" Hg is entered into the altimeter, and so now everyone is flying at a constant altitude above NOT mean sea level, but above a reference plane. And altitude is no longer reported at 15,000', but as Flight Levels -- FL 190 for what would otherwise be called 19,000', etc.
This means that FL FL400 isn't really 40,000' above sea level most days, and on some days it's higher than that, and other days it's lower, but as long as everybody assigned to fly at FL400 is at the same altitude (which they are, all having 29.92 set in their altimeters), everything works. (Particularly since everybody at FL400 is 1000' above everybody at FL390 -- that's what we really care about!)
Altimeters are connected to a static pressure port, a little vent that's outside the aircraft. This senses the pressure in the outside air. For the altimeter to update with the correct altitude, it senses differences and changes in air pressure. As an aircraft climbs, the pressure decreases, and the altimeter registers an increase in altitude.
But what happens if you're on the ground, and the atmospheric pressure changes over time? You need to calibrate your altimeter.
Since altimeters are extremely sensitive to air pressure, a slight change can register a big difference. There is normally a knob, which lets you calibrate it. It allows you to adjust the readings in the air pressure, known as Inches of Mercury. Generally, the expectation is that this setting is at 29.92 inches of mercury.
As aircraft move into areas with differences in air pressure, pilots have to adjust the altimeter to account for this. Pilots will normally be notified by the ground when flying at local altitudes, for example during approach or 10 000 AGL. Re-adjusting is simple: just turn the knob.
As seen in the picture, you have the altimeter. To the bottom-left is the knob to adjust the readings. The little numbers on the right indicate the current observation in Inches of Mercury. Here, it is 29.92.
I think that the question has been answered by a couple of great answers, so there's only one thing I can add.
In my opinion the main reason for the transition from QNH to QNE is so that above the transition altitude, the airplane, engine and systems always perform the same way. For example, for every possible load-out, there's a certain optimal altitude for the plane to fly at. In truth, this altitude is really a pressure, that only converts into an altitude by assuming a standard pressure above a simulated reference plain. In other words, it doesn't matter how hot or cool it is or where around the globe you are, if you convert your outside pressure into a reference altitude, you can always fall back to the same performance tables.