Words have meanings just as phrases do. The meaning the phrase "Loose Cannon" is described here.
A story about the phrase loose cannon comes from the book “Ninety-Three” by Victor Hugo written in 1889, that tells a story about the Gunner of Claymore.
During days of sail, in rough seas, a cannon comes loose on the deck of the French corvette “Claymore”, and it’s one of those big deck guns that just wreaks havoc everywhere as it rolls on and moves about. It’s one of the carronades of the battery, a twenty-four pound cannon, perhaps the most dreadful thing that can take place at sea. Much literary allusion about a cannon that breaks loose from its fastenings is suddenly transformed into a supernatural beast. It is a monster developed from a machine. Nothing more terrible can happen to a man-of-war under full sail. The gunner, like a matador or a lion tamer who avails himself of a perilous opportunity, thrusts an iron bar between the spokes of the back wheel and slips a rope to hold the cannon fast just before it crushes one of the passengers, an old man. It was the gunner who had so opportunely displayed his power as a tamer of monsters, and gained the victory over the cannon.
Moments later turning to an official aboard known as the Count, the old man the gunner had just saved removed the cross of Saint Louis from the captain's breast, and fastened it on the jacket of the gunner in front of the crew. The sailors cheered, and the marines presented arms. Then pointing to the bewildered gunner he added: "Now let the man be shot! The ship has been endangered by an act of carelessness, and may even yet be lost. It is all the same whether one be at sea or face to face with the enemy. A ship at sea is like an army in battle. The tempest, though unseen, is ever present; the sea is an ambush. Death is the fit penalty for every fault committed when facing the enemy. There is no fault that can be retrieved. Courage must be rewarded and negligence punished."
These words fell one after the other slowly and gravely, with a certain implacable rhythm, like the strokes of the axe upon an oak-tree. Looking at the soldiers, the old man added,—"Do your duty!"
The man on whose breast shone the cross of Saint Louis bowed his head, and two sailors brought a hammock-shroud and the ship's chaplain, the sergeant detaches from the ranks twelve soldiers, whom he arranged in two rows, six men in a row. The gunner placed himself between the two lines. The chaplain, holding a crucifix, advanced and took his place beside the man. "March!" came from the lips of the sergeant; and the platoon slowly moved towards the bow, followed by two sailors canning the shroud. A gloomy silence fell on the corvette. In the distance a hurricane was blowing. A few moments later, a report echoed through the gloom; one flash, and all was still. Then came the splash of a body falling into the water. The old passenger, still leaning against the main-mast, his hands crossed on his breast, seemed lost in thought. Ending the story of the Gunner in the chapter here. You see both sides of the scale of justice balanced perfectly. His courage must be rewarded and his negligence punished. He gets both. But if you’re the one responsible for a loose cannon, in the end you must die.