And weren't those captains allowed to keel haul, lash and hang people/crew
They were allowed to impose the sentence prescribed by law or service regulations after a finding of guilt in a proper proceeding.
In the Royal Navy, the captain could try minor offenses by the enlisted crew, such as drunkenness or sleeping on watch, by himself, and impose flogging up to twelve lashes, forfeiture of pay, stoppage of grog or disrating of most petty officers.
More serious offenses, and all charges against officers, required trial by court-martial, which had to be called by a fleet commander required at least five captains and/or flag officers. Death sentences had to be confirmed by the Admiralty in London, or by the fleet commander-in-chief if on a distant station. A well-known example from this period was the
Bounty mutiny, where the frigate
Pandora was dispatched to round up the mutineers and transport them back to be court-martialed, which it did but was wrecked on the return trip.
A ship's captain had no authority to punish civilians, except to deliver them to a court with jurisdiction.
The new and much smaller US Navy basically adopted the Royal Navy's legal system with minor modifications.
Keelhauling was not a legal punishment in the British or US navies, nor is there much record of it in navies at all. Though there is evidence that it was used as a form of torture in antiquity, by the time we are talking about it was more of a scary legend.
It would seem out of order for a modern naval captain but thats not what we are talking about here.
So would it seem in order for a starship captain to impose corporal punishment on a crew member? That was one of the things that strongly differentiated the mirror Starfleet.
Did he really "let them go" though?
Legally, he did. He dropped all charges.