Why is `a5` a better move in this position? I was playing with a friend and we come to the following position (me white):


My friend played b5 but computer analysis says that this is a mistake and he should have played a5. Now, I don't see why is that better? 

Can anyone help me please understand why?
First, you need to see that in the original position, Black has already a close to winning advantage. Especially the pin on f3 is nasty; it's hard for White to defend the knight now that the bishop is 'offside' and Black can easily attack it with another piece (Qf6).

Both moves (a5 and b5) share the same idea: gaining space on the queenside, with tempo. The move a5 doesn't attack anything but threatens to trap the bishop. The move b5 has a deep tactical refutation involving a (temporary) queen sacrifice:

[FEN "r2qkbnr/pp3pp1/2pp3p/4p3/B2nP1b1/2NP1N2/PPP2PPP/R1BQ1RK1 b - - 0 1"]

1... b5 2. Nxd4!! Bxd1 3. Nxc6 bxa4 4. Nxd8 Bxc2 5. Nc6 Bxd3 6. Rd1 Ba6 7. Nd5


and White has more than enough compensation for the pawn; center control, space advantage, advantage in development and a better pawn structure. (Immediate tactics on c7 look promising but aren't.)

Black is better off trying to hold on to the queen, but he'll have trouble protecting his king from the dangerous bishop-knight battery:

[FEN "r2qkbnr/pp3pp1/2pp3p/4p3/B2nP1b1/2NP1N2/PPP2PPP/R1BQ1RK1 b - - 0 1"]

1... b5 2. Nxd4!! Bxd1 3. Nxc6 Qh4 4. Bxb5 a6 5. Ba4 Bxc2 6. Bxc2 Be7 7. Ba4 Kf8 8. Nd5


This is an unbalanced position with chances for both sides; in any case, much less than Black started out with.