Why do miniature games happen at the grandmaster level? It is often said that grandmasters calculate many moves in advance before moving a piece. 
If this is so, why do miniature game (games less than less than 25 moves long) happen?
Your statement, Grandmasters think of next many moves ... is a bit misleading for your question. 

Grandmaster are able to calculate many moves ahead, but this is not something they do at each and every move. Basically, as for the start of the game, the first 10 or 20 moves are played from memory (known opening repertoire + home preparation) and not found over the board.

Even when the home preparation ends, players usually do not start calculating  like crazy all possible moves to depth 20. They would rather (also see here):


evaluate/analyze the position based on general principles and experience
depending on this analysis develop a general plan (Should I improve piece activity? Should I play against an opponent's weakness?....)
come up with concrete (candidate) moves
calculate the consequences of the candidate moves: Depending on the position at hand this can be many moves ahead (e.g. in tactical or forced lines) or it can just be a single move, basically just checking whether you don't blunder something (e.g. in less tactical, more positional games where it is just practically impossible to calculate all possible lines)


So how can grandmasters lose in less than 25 moves?

They are humans so not perfect and might make mistakes. In this case they can go wrong at basically each part of the thought process:


They might mix up memorized opening theory, confusing lines and thereby making a bad move. Occasionally they might run into a strong opening novelty prepared by the opponent in which case even playing the commonly accepted opening line can bring them into trouble. Also there is the funny story around the Zapata-Anand miniature where Anand apparently blindly followed published opening theory (informator) of a Miles-Christiansen game which was a prearranged draw but in fact included a huge blunder.
They might evaluate the position wrongly, e.g. underestimate a threat.
They might come up with a plan that is impossible to push through or pick the wrong plan out of a choice of plans.
They might miss a possible candidate move
They might  make a mistake in calculation.


In addition any combination of the above is possible.