Robb is a 15 year old and he fucks up just like any 15 year old would. Walder Frey is an old bitter man and he saw an opportunity. There's a lot of this going on and some of it even predates the books. During the battle of the Trident and the fight for Robert's crown there were lots of people who suddenly switched sides at the end once they realized that the Baratheons were winning. What made Robert a good king was that he forgave them.