Why that happens is due to the aircraft's inertia.
Consider a fairly simple case: an aircraft is flying due north, straight & level, with a constant 100 knots of indicated airspeed (KIAS) and a 10 knot headwind. So its velocity over the ground is 90 knots. There is some amount of thrust being produced, and some amount of drag, and those are in balance, just as lift & weight are in balance. Everything is stable.
Now let's assume that the wind suddenly goes from 10 knots out of the north, to 20 knots out of the north in a very short span of time -- say, a couple of seconds. The inertia of the aircraft is still 90 knots over the ground, but now there is more air blowing at it... that 90 knots of groundspeed and 20 knots of wind makes for 110 knots of indicated airspeed, at least at the moment that everything changed.
Assume that the pilot (or autopilot) holds altitude, but doesn't adjust the throttle. Same thrust as before, but with the increase in airspeed you now have more drag, and so the forces are no longe in balance. Over time, a minute or so perhaps, the airspeed will slowly decrease, since drag is greater than thrust, until you reach a new equilibrium state, back at 100 KIAS. But now, 100 KIAS and the 20 knot headwind means the new groundspeed is 80 knots instead of 90. Once everything gets into equilibrium, the greater headwind translates into reduced groundspeed.
But until things are back in equilibrium, the increased headwind hasn't fully reduced the groundspeed -- for a time, the greater headwind increased the airspeed, until things have a chance to get back into balance. How long it takes for things to get back into balance depends on the magnitude of the forces involved... if your airplane was a small model airplane cruising at 15 or 20 knots with only enough thrust to overcome the fairly slight drag on the small airplane at that slow speed, then the 10-knot boost would be a huge increase in drag, and its groundspeed would bleed off within seconds as the forces quickly reached equilibrium. On the other hand, if you have an A380 at 300 knots get the same gust, the delta in drag from 300 knots to 310 is going to be real, but comparatively smaller when you consider how much thrust & drag are already present... it won't react nearly as rapidly to that same change in the wind. It will reach equilibrium at 10 knots less groundspeed than before, and the same IAS as it started with, but it won't do so as quickly as the model did.
Now apply that to the windshear scenario... an airplane is on approach to runway 36 (i.e. flying north) at 70 KIAS with zero headwind and on glide path, and it flies into a microburst. The south side of the microburst has air flowing from the center of the downdraft outward, so south flow. The airspeed increases from 70 knots to 90 knots within a few seconds. Rather than wait for everything to get back into equilibrium, the pilot reduces power and raises the nose with the intention of holding glidepath and correcting the airspeed. Now the drag is greater than before due to the higher airspeed, and the thrust is less than before, so the indicated airspeed is coming down quickly. Let's say it's just back to the 70 knot target speed, when...
Now the airplane flies into the core of the down-draft, which removes the headwind and causes the airplane to sink. And then, the airplane flies past that to the north side of the microburst, where the outflowing winds are a tailwind of 20 knots. The aircraft's groundspeed was roughly 50 knots (back at the target 70 knots airspeed, with the 20 knot headwind, before it goes away), but now it suddenly has 20 knots of tailwind... before things get into equilibrium again, your 50 knots of groundspeed and 20 knots of tailwind means your IAS falls off to about 30 knots. You went from a 20 knot headwind to a 20 knot tailwind, a change of 40 knots. The approach speed of 70 knots, which the pilot had just regained before losing the headwind, drops toward 30 knots -- the amount of power and trading altitude for airspeed required to avoid stalling the aircraft as the airspeed has 40 knots robbed from it within a few seconds, may be more power and altitude than is available.
Which is why windshear, and microbursts especially, are such serious business.
But the "why" behind it all is inertia. The wind velocity can change quite rapidly, but the aircraft's velocity over the ground (or in 3-dimensional space, if you prefer) doesn't change as quickly, so the delta is reflected in the airspeed, until things are back in equilibrium.
If the 20 knot change in airspeed happened over 10 minutes, you'd hardly notice... the airspeed would start to drop off a little, the pilot would add a little power to restore his desired speed, and the higher power setting would balance the slow loss of speed, so that you'd see no loss of airspeed on the instruments, but rather a slow decrease in groundspeed. But when the wind velocity changes suddenly, the airspeed will change faster than power changes can compensate, and you observe the gain or loss of airspeed, as described in the OP.