If you look at Board 2, and it is white's turn, consider what happens if you move the Queen to F7. Or, if it is black's turn, and Black moves to E7, consider what happens if the queen moves to G7.
The answer is that Black will have only one legal move. White can respond each turn by getting one step closer to Black, until White can force the checkmate.
Although, white needs to be careful about this. By reducing Black's movement possibilities by one square each time, white could force Black into a position of placing the King in the corner and getting stuck. That is fine, but white is then required to either checkmate immediately, or provide Black with a little bit of additional leeway to be able to move again, or else White will cause a Stalemate and white will lose the ability to win the game. (At this point, if those are the only pieces on the board, such a Stalemate is the best that black could hope to accomplish. However, Black can't force a stalemate from this position. Black can only hope that White makes an error.)
So Board 2 is not showing Checkmate, but that board may still be useful to think about for educational purposes.
I agree that the book is not abundantly clear, as the way that the book phrases things could be interpreted to suggest that checkmate has been accomplished. However, without question, checkmate has not yet been achieved in Board 2. Board 2 is just showing a somewhat common situation where checkmate can be achieved relatively easily, and soon. In this scenario, if there are no other pieces, white is unlikely to be thinking about defending itself, or how to reduce the number of pieces on the board. Instead, white will be focused on how to obtain checkmate soon, as a realistic short-term goal. Think of "Checkmate with king and queen" as a topic, or better yet, as an instruction, not as a description of what has already been accomplished.
Note: Board 1 is not something I've seen very often. In order to get into that position, Black would need to have been on B8, and the queen place the king into check by moving to B6, and Black move into the corner. This is unlikely, because Black's usual best strategy in this type of scenario is to move as close to the center of the board as possible. Instead, by going into the corner, Black allowed for an easy Checkmate. Although, if white moves to B8 as one of those red arrows suggests, then white will lose the ability to win the game (assuming there are no other pieces), so white should definitely not do that. I think the Red arrows are just trying to show relevant squares where white's queen can attack, thereby demonstrating black's inability to move to those squares.
Isn't checkmate when the king piece is in check and there is no legal moves it can make?
Almost. When you say "it", the sentence looks like you're referring to the king.
Checkmate is when the king piece is in check, and there are no legal moves that the player can make. (If the player can legally move a different piece, then it is not Checkmate. Note that any legal move will require getting the King completely out of check.) So if "there is no legal moves" that the king "can make", but if a knight can get in the way of the piece that is threatening the king, then this is not checkmate.
Thus in the second example it isn't in checkmate because the king can still move around on the 8th rank and there is no immediate danger to it so it isn't in check either...
You have assessed this correctly.
Or does checkmate also include being trapped in a certain row, column or diagonal length with no other moves you can take except to move along those boxes?
No. Such restrictions have nothing to do with checkmate. If the king gets into the middle of the board, but then gets threatened and the player cannot eliminate that threat, then there can be checkmate even with the king being in a very different location. (Since it takes some time to get the king to the middle of the board, this isn't very common. When it does happen, often the player who is moving that king already has a rather unpowerful army remaining.)