One of the early developments in weapons capable of firing multiple shots before reloading was the Puckle gun, which we already studied some time ago. This was invented in 1718 and is the precursor of the revolver.
A Puckle gun. Click on the image to enlarge. Public domain image.
There were also other multi-shot weapons invented later, such as the Mitrailleuse gun and the Belton flintlock, but the first real practical machine gun was the Gatling gun, invented by Richard Gatling in 1861.
In order to have a rapid firing weapon, it was necessary to have a way to automate/quicken the reloading process and the invention of the cartridge came in handy here. Early gatling gun models used paper cartridges and percussion caps, because these were the same technologies used by US Army infantrymen of that era -- in fact, the Gatling gun was designed to use the same caliber cartridges. However, this model was prone to jamming. The second model used the rimfire cartridge instead. Rimfire and centerfire cartridges made the Gatling more reliable. Metallic cartridges also made it possible to provide a better seal in the chamber of the firearm, because the hot gases from a fired cartridge expands the metal case and seals the back of the chamber.
Another technology that made it possible for modern machine guns was the invention of smokeless powder. Early Gatling guns used black powder cartridges. With black powder, the smoke rapidly makes it hard for the operators to see what is going on. On top of that, black powder leaves behind a lot of dirty residue and this can cause the mechanism of a machine gun to jam. Smokeless powders produce a lot less residue, therefore the gun can fire for longer periods without risk of jamming.
Improvements in metallurgical techniques also helped, because it made it possible to make gun parts which perform reliably for extended periods of time and resist heat better as well.
With that said, heat dissipation has always been a problem in machine gun design. In the case of the Gatling gun, the problem was solved by using multiple barrels. With multiple barrels, the weapon can fire at a higher rate, but each barrel is rotated after each shot and therefore has time to cool before it fires another shot. However, the presence of multiple barrels makes the overall weapon heavier. Water cooling and quick-change barrels are other techniques that were historically used by other machine guns to solve the same issue. Interestingly, the use of multiple barrels in a gun was revisited in modern times, with the invention of the minigun and the multi-shot cannon used on the A-10 Warthog aircraft.
Also, the idea of using an electric motor to power a gun is a lot older that most people realize. In fact, in 1893, Richard Gatling received a patent for a gatling gun powered by an electric motor!