There are a few ways to accomplish muzzle brakes, but generally, they work by diverting some of the concussion created when a bullet is fired forwards and to the sides, away from the shooter.
This is accomplished either through open ports or expansion chambers that redirect gasses exiting the muzzle.
The result is often drastically increased control over firearm recoil, particularly found on larger caliber weapons.
Additionally, muzzle brakes can be very effective at reducing reflections back towards the shooter from low light conditions or hiding spots, furthering their utility.
Some even have happy side benefits like concentrating more heat near the front sight (to counter historical problems with older night vision devices), which has given some name brands notoriety among competitive shooters.