This question already has an answer here:
This is a case of stalemate. Black has no legal moves available, therefore the game is drawn.
This type of situation is called a stalemate in which the opponent is unable to play the next move ( probably because of king's check) but is not completely checkmated. To avoid it, ensure that you completely mate the opponent king. The probability of this kind of situation occuring is increased when you have more pieces (like Rook, Queen which can mate the king) and you don't actually know which piece is already blocking the opponent king's road beforehand.