Magnetic activity in the form of magnetically powered flares, hot X-ray emitting coronal, UV-bright chromospheres and starspots is driven by an interior stellar dynamo. Whilst the details of how this dynamo works is still to some extent mysterious, the basic ingredients are agreed upon and can be empirically observed - those ingredients are fast rotation and an outer convection zone.
Fast rotation and convection generate and amplify magnetic fields and their buoyancy then brings them to the photosphere and corona. The convection and surface (differential) rotation then jiggle, shear and twist the magnetic fields, injecting magnetic potential energy that can be violently released in the form of field rearrangement, particle acceleration and consequent heating and flare emission.
M-dwarfs either have deep subphotospheric convection zones, or below about 35% the mass of the Sun, may be fully convective. As a result, for a given rotation rate, they tend to be more magnetically active than solar-type stars that have thinner convection zones; however there are two key features which lead to them being considered especially inhospitable to life.
Firstly (and I think the main answer to your question), both solar-type and M-dwarf stars begin their lives as rapidly rotating objects, with periods of a few days to a few hours. As a result, the Sun would also have been orders of magnitude more active than it is today. The difference between solar-type and M-dwarfs is that solar type stars spin-down and become much less active on timescales of a few hundred million years, but for M-dwarfs this process takes many billions of years. Thus they remain fast rotating and have relatively high levels of magnetic activity on timescales of the age of the galaxy - never giving any surrounding planets the chance to have billions of years of relative calm as in our own solar system.
Secondly, M-dwarf planets in the "habitable zone", where their equilibrium temperatures are suitable for liquid water, are much closer to the star than is the Earth to the Sun. That is because their overall luminosity is much lower and so the ratio of "magnetic activity emissions" to bolometric luminosty is higher for the same absolute level of magnetic activity. This means that the harmful radiation due to magnetic activity is comparatively much more intense and damaging for habitable zone planets around an M-dwarf.