According the the film's official novelisation, the cannon belonged to the community of Haven where it was used as a civilian defence tool;
Sadly, the town proved a powerful reminder to Mal of Lilac—several shacks, not as ramshackle as on the other moon, but indicative of the same hard living. They also had a church, which got more use nowadays, and a smal vegetable patch, which was another of Book's contributions to the community.
One thing they had that Lilac didn't—and could rightly have used—was a large cannon, salvaged off a warship some years back. It was the main thing that kept Haven living up to its name.
Dozens of townsfolk came out to greet them, including Doane, who had cannon duty today. He jumped down from the chair that had been attached to the cannon and gave Mal a hearty handshake. Little Hiroko ran toward them at top speed, yelling.
It's also explained that this is the cannon that Book used to shoot down the raider.
Without another word, Book ran over to the cannon. Gently removing
Doane's body and laying it on the ground al respectful-like, he then
leapt into the firing chair and whirled it on the Alliance ship just
as it finished raining down fire on the shepherd's own church and
adjoining garden.
Though Bernabe didn't rightly recognize the specific class of ship, he
was familiar with the design type behind it. Was fair similar to the
Striker-class that the Alliance favored during the war. This was
souped up beyond all good sense, but Bernabe figured the engine core
was in the same place.
He knew this mainly because Book's first and only shot went right to
the spot on the undercarriage where Bernabe reckoned the core was.
This is fully confirmed by the film's screenplay
It is a world of fire.
Every building burns, some blown right apart. Bodies litter the scene,
not one of them moving. There's a grounded Alliance ship not far
from the cannon that shot it down.
INT. BRIDGE - CONTINUING
We see Mai's face as the sight hits him like a gut-punch. EXT. MINING
CAMP - MOMENTS LATER The crew pours out even as the ramp lowers, going
off in all directions, calling out to people...
Kaylee heads for the burning church.
shortly later...
MAL: Jayne, you and Wash hoist up that cannon mount. Goes right on top. Piece or two of the other ship, stick it on. Any place you
can tear hull without inner breach, do that too.
(looking around) And we're gonna need paint. We're gonna need red
paint.