When Edward and Alphonse try to transmute their mother, how come they didn't gain anything? So, to my understanding, the idea of alchemy is equivalent exchange, in which you get in return as much as you gave.

This doesn't make sense to me, as in the beginning when they tried to transmute their mother back, Alphonse lost everything, and Edward lost his leg. They didn't get anything in return, or at least anything worth of a soul and a body. After this Edward transmuted his arm to get Alphonse back.

So, put in a calculation:

Things lost


Random piled ingredients which were supposed to compose the average human
Alphonse's body
Alphonse's soul
Edward's arm
Edward's leg


Things gained


A blob of purple stuff with Alphonse's soul affixed to it ( for a while )
Alphonse's soul


So, where the hell did the rest of the stuff go? And more importantly, why could they not just have transmuted everything back?
Unmarked spoilers for both Brotherhood and the 2003 series follow.

You're missing a key bit of information: they did gain something for their loss[1], just as Izumi did.

The boys gained the knowledge of what was beyond the gate. Unparalleled truths of alchemy reside beyond the gate, and no mortals are ever allowed access to it&mdash;unless they commit the taboo.[2]

Both Edward and Alphonse were shoved through the gate and absorbed as much material as they could from it, Edward even wanting to go back to get more. In the 2003 series, Alphonse never recalls this, though in Brotherhood, he recalls it after having blood spilled on his seal. Ed remembers it from the beginning, and this knowledge is what allows him (and later, Alphonse) to transmute without a circle.

The reason they couldn't just transmute everything back is because they had already committed the sin. If you steal something, and are caught, but then give it back, do the police let you go? No; and this is also the way of The Truth. Performing the sin is the punishable act; transmuting it back would be futile.

1 &nbsp; Keep in mind that by the end of the series (at least in Brotherhood's case, original FMA was not as forgiving), much of what was lost is regained through further equivalent exchanges.
2 &nbsp; It's a bit more complicated than this, but it will suffice for this explanation.