Why fianchetto the bishop? Why do people fianchetto the bishop? I know that fianchettoing two bishops (black and white) in b2 and g2 protects the entire black and white diagonals but honestly i never understood these reasons


  
  What are the fianchettoing advantages and will it improve the position? 
  When to fianchetto the bishop?
  


In my personal experience, I try to fianchetto the bishop when i castle kings side. This greatly sets up a great defense wall.
The answers to your two questions are related.

Fianchettoing a bishop allows the bishop to attack the center from the sidelines, from the second rank. Normally the bishops would have to go to the fourth rank (c4, f4 for white) or the fifth rank (b5 or g5 for white) pinning an enemy knight to have an influence on the center.

If you are going to play a classical opening with d4 or e4 (as white) then you probably want to develop your bishops classically as well to the 4th or 5th ranks, although you can still fianchetto them if you want.

If you are going to play a hyper-modern opening (Reti, Kings Indian, Pirc, etc.) where you cede the center to your opponent (don't challenge your opponent's central pawn moves with your own central pawn moves) then fianchettoing becomes much more important in the fight for control of the center. Not only will the bishop help you fight for the center but the pawn on b3 or g3 (for white) will help you with a further pawn break like c4 or f4 to undermine the opponent's center.

As a defensive move, fianchettoing the bishop on the side where you castle is not so straightforward. It creates weaknesses as well as strengths. If your opponent can force an exchange of the bishop you will be left with weak holes on f3 and h3 (for white kingside castling and fianchetto) and your pawn on g3 can be a target for an aggressive opponent to rapidly push his h pawn to try and embarrass you.