When it encountered Graham, it brought him to the prison through a portal. When he escaped from that prison cell, he sought out the king again to imprison him in a different cell -- but this time, the king was ready and tossed a bag of dried peas on the floor. The Blue Beast tripped on the peas and crashed to the floor. Although Graham had defeated him once, the beast was gone when he passed where it fell. He had to be careful to avoid it again.
The "Blue beast" is a character in King's Quest V: Absence Makes the Heart Go Yonder.
This character is only listed as the "Blue beast" or "blue beast" in the KQ5 hintbook, the second word 'beast' is never capitalized officially. It is given the title Mordack's Henchman in the King's Quest Companin, in An Encyclopedia of Daventry.
Though the beast can be defeated the one time, the player must be careful not to be caught again, as the beast will reappear. This was partially to avoid a possible 'dead end' in which the player uses the peas before going to the dungeon. But the player must avoid going to the dungeon if they do not befriend Cassima, or avoid going to the dungeon a second time, this leads to a death situation.
It is possible to encounter the 'blue beast' outside the castle, if the player forgets to bring the metal bar to the island. The blue beast will open a portal outside the castle near the grate, and grab Graham and carry him to the dungeon.