As has already been suggested, rule out pain or tack fit first.
Think of it this way. You're training for football. And you've got a broken hand. Sure, you can run and down the field no problem pain free, but when you try to throw, or catch yourself doing up-downs, it hurts. Now imagine your coach chewing you out because your throws stink, and yelling at you to hurry up and do your up-downs correctly. It's not that your not trained or not trying. It's that is HURTS!
That's why it is always a good idea to rule out pain or tack fit when working with an unfamiliar horse or with an "attitude" problem that seems to arise out of the blue.
If you discover that the horse is not in pain, then you can work on the behavior and fixing the attitude. If the horse doesn't want to gallop, make sure you MAKE them gallop. By bucking, they are trying to get out of work. If you allow them to get out of work, guess what? The horse "wins" and gets what they want. Do circles, figure 8's, and whatever at the gallop and do not stop until YOU ask the horse to stop (not when the horse decides to throw a bucking fit). You don't have to be abusive or spur excessively or any of that. But you do need to be firm and consistent every single time.