When to fianchetto


ok the GM game I just googled and picked out in like 5 seconds, it could've been any position where someone fianchettos

But in your example game there isn't even a fianchetto.

It's almost always in hypermodern openings. They place the bishop on the longest diagonal so it attacks he center from a distance.

In the opening Black could try and develop the light-squared bishop outside the pawn chain. It just leads to a different type of position with different pros and cons. Keeping the bishop in the chain is a solid plan while getting it outside the chain tends to be more dynamic.
In the first position the bishop is not very active on b7 but it does hold Black's extra pawn. Black is putting the bishop on b7 to simply be able to keep the extra pawn and to prevent tactics (like a2-a4) that White could use to win it back. Some players like the extra pawn. Others don't want their bishop boxed in like that even for an extra pawn.
In the second position Black is fianchettoing the bishop to try and control the e4 square. The moves ...Nf6, ...Bb7 and ...Bb4 are all designed to add pressure to that square and to keep White from being able to control it. Black is able to influence the center here without actually putting pawns or pieces directly into it. That's usually the point of fianchettoing a bishop.
You don't really lose a tempo when you fianchetto a bishop but there are some positions where it is too slow to play that way. For example:

I have been nailed by an early fianchettoed bishop more than once. He sits there so long you forget about him and then BAM! You move a pawn and he grabs your rook. It happens to me ALOT (even though I seem to know about it)

lol this is quite useless with respect to the thread, but I was playing in an OTB tournament today and a game next to me (between a very young 1800 with white and a 2100 friend of mine with black) began like this:
This would be an example of when not to fianchetto a bishop. Black continued with ...c5 and gained an early advantage, later winning. The player with white is very young and maybe can be excused, but still.
All of the responses you got so far excellent. Especially penandpaper0089.
From studying endgames I discovered a little known fact about Bs. For 300 yrs. the endgame of K+2Bs vs. K+N was assessed to be a draw, even though it had been studied and analyzed extensively before the age of computers. The computers number crunched their way to a forced win with a couple of exceptional positions that ended in draws. GMs studying the computer's technique discovered that when a B goes to the edge of the board on one diagonal. On its next turn reflecting on another diagonal it gains a tempo.
When you fianchetto a B you are reflecting off the edge of the board onto another diagonal. It is quite possible that although it takes at least 2 moves to fianchetto. The tempo that you gain makes it as though you only made one move (one tempo).

Black often doesn't have the option of developing the QB to a good square without weakening b7 too much.
To develop a Bishop, you need to push a pawn and move the Bishop, except is special positions. Fianchettoing the Bishop does not cost a tempo and pressurizes more of the center than any other normal developed Bishop.
It your first game, Black made 9 pawn moves and White made 4. This is the reason that black in behind in development, not the development of the Bishop.

This is one of the most common modern openings and black actually wins more than loses out of this position at master level. I like to Fianchetto....and win my share playing black. To control the center, it only necessary to have pieces attacking it....and we have all fallen pray to the lost rook blunder before, you are not alone LouStule

All I can offer at the moment are a few guidelines for when and when not to fianchetto:
(1) As mentioned by Brobotics above, *do* fianchetto if your strategy is hypermodern since fianchettoing is an important part of that strategy. The idea is to control the center from the flank, to be noncommittal, and to use your opponent's center against him. I agree with Urk, though: as a beginner it's better to stay away from hypermodern openings because there's just too much to know.
(2) Do *not* fianchetto if the side on which you're planning to fianchetto has two head-to-head middle pawns. For example, if you're White don't play 1. e4 e5 2. g3 because that center can be locked up for a long time, which will put your bishop out of commission. I know Carlsen shows off with getting away with breaking such guidelines, but you're not Carlsen yet.
(3) *Do* fianchetto if you've been forced to move your NP to N3 and you haven't developed the bishop that could move into N2. That way you're making use of the P-N3 tempo instead of losing that tempo. The main opening that comes to my mind where that happens is the following:
(4) *Do* fianchetto if you like that way of nullifying the opponent's fianchettoed bishop. For example, Fischer would always (I believe) fianchetto as Black via ...Bb7 in the Sicilian Najdorf whenever White fianchettoed in that opening via Bg2. There exist other ways of nullifying a fianchettoed bishop, however, such as playing ...P-B3 so that the opponent's fianchetto bishop bites granite.
(5) *Do* fianchetto in some openings where your opponent wants to send his f-pawn into your castled side, such as Black playing ...f5, then ...f4, and maybe ...f3 in a double e-pawn opening. In that example, g3 discourages ...f4 since Black would just lose his f-pawn needlessly if he played ...f4. One opening that comes to mind with this situation is this one:

There seem to be two basic fianchetto scenarios: (1) fianchettoing to get a bishop on a good square (White in the English or Catalan, Black in Queen's Indian/Grunfeld) and (2) fianchettoing because of the pawn structure (Black in King's Indian or in Tratakower defence to QGD - in the latter case bishop sometimes goes to e6 anyway). 1.Nf3 and 2.g3 is an interesting case - White is ready to play for both plans, depending what happens in the center.

From studying endgames I discovered a little known fact about Bs. For 300 yrs. the endgame of K+2Bs vs. K+N was assessed to be a draw, even though it had been studied and analyzed extensively before the age of computers. The computers number crunched their way to a forced win with a couple of exceptional positions that ended in draws. GMs studying the computer's technique discovered that when a B goes to the edge of the board on one diagonal. On its next turn reflecting on another diagonal it gains a tempo.
When you fianchetto a B you are reflecting off the edge of the board onto another diagonal. It is quite possible that although it takes at least 2 moves to fianchetto. The tempo that you gain makes it as though you only made one move (one tempo).
Heavy. I'd never heard of that endgame or that study, and the use of human brains to detect patterns among solutions found by computers by brute force is very interesting to me. That's the kind of task I'd love to see programs do, which would push the state of the art in chess in a more meaningful way than producing yet another collection of endgame conclusions stored in a database. The result would be knowledge that humans could use, and an abstraction of the noisy underlying data. I don't understand what you mean about how a reflecting bishop could gain a tempo, though.
Oh, and one more generality for my list, for laughs:
(6) Do *not* delay placement of your bishop in a fianchetto if such a delay leaves your B3 square open for a knight to deliver a quick smothered mate in the opening. OK, I'll admit it: I lost to the computer once when I did that, though unfortunately I was too ashamed to save the game.

There are a lot of answers here that are more or less correct. However, they are too complex for a player of your rating. Once you reach daily rating of 1300+, then come back and ask again.
For you, I would recommend the simple, yet effective rule:
*If you can develop the bishop in one turn without fianchettoing, then just develop normally - otherwise, you can consider fianchettoing.
Obviously, if you're dropping a piece or pawns by doing one thing over the other, then the material takes precedence.

"An example: Aronian vs Anand 2007..."
I would suggest studying games of the old masters instead. The themes involved will be simpler and clearer than modern master play. GM games are instructive for GMs.
Try Reti - Bogoljubov New York 1924:
http://www.chessgames.com/perl/chessgame?gid=1030774
@Squod: You can find the details In GM John Nunn's Secrets of Minor Piece Endings.
Here is thee clickable Amazon Books internet address:
https://www.amazon.com/Secrets-Minor-Piece-Endings-John/dp/071347727X/ref=sr_1_1?s=books&ie=UTF8&qid=1487077155&sr=1-1&keywords=Secrets+of+Minor+Piece+Endings
This question consistently bothers me. I have been learning alot of chess strategy/positional play type things just from reading books, watching videos and conversing with masters, but one thing that has always 'felt bad' I guess is fianchetto-ing a bishop. One of the biggest reasons why is because in early game situations, particularly playing black. I sometimes find positions where a bishop is sort of boxed in. Even more perplexing, boxing in the bishop is sometimes mainline theory for popular chess openings.
An example: Aronian vs Anand 2007
One last thing I want to ask in regards to fianchettoing is this. And excuse me as I'm having a hard time putting my question into words but here goes: When you fianchetto isn't it true that you are either losing a tempo, or losing control of the center? I was simply messing around in stockfish to illustrate my point. Here black has fianchettoed a bishop and hasn't lost a tempo via opening two doors for the bishop, but has lost total control of the center correct? Why is this not god awful for black? halp
I hope some of you have answers to the questions in that game. Black also ends up winning this game which means I'm missing something. halp
EDIT: sorry for the picture being a weird resolution, hopefully you can zoom in and just see the position.