Physical Processes in Magnetically Driven Flares on the Sun, Stars, and Young Stellar Objects