It's usually because they just need more fitness and muscle development in their back and hindquarters. They're not being naughty, or bucking to get you off, it's just uncomfortable and feels unbalanced for them to try to transition from a balanced trot to a steady canter/lope. It's easier for them to run faster and faster in the trot and get up enough momentum to go into the canter, than to get their inside hind leg under them, take their whole weight on that leg, and smoothly take off into a canter/lope. They buck (usually it's more of a crow-hop really) to get their whole hind end off the ground and give themselves time to figure out how their hind legs should land, instead of immediately stepping under themselves with the inside hind, like a fit, trained horse will do when asked to canter/lope.
Often we riders will get unbalanced or grab the reins when they do their "crow-hop" then it can sometimes turn into a bucking festival which is no good for us or them...the best thing to do when this happens, is keep your weight over your stirrups, your upper body over their center of gravity, hands steady and keep sending them forward, even if they're unbalanced. Tell them good boy or girl when they finally canter, and let them keep going until they find their balance.
To prevent this from happening in the first place, try to help them build good balance and strong back and hindquarter muscles before you ever ask for the canter. Do lots of walking and trotting up and down hills. Do lots of walking and trotting over poles on the ground (set them 4 feet apart).