Specifically, what causes them, what sort of damage can they cause, and what are the differences in their composition?
The following definitions are according to NASA.
"Solar Flares" are gigantic explosions from the surface of the Sun, occurring near sunspots along the dividing/neutral line between opposite magnetic field areas.
"Coronal Mass Ejections" (CME's) are:
huge bubbles of gas threaded with magnetic field lines that are ejected from the Sun over the course of several hours.
Although the Earth's magnetic field protects the biosphere from the worst of these forms of 'space weather', according to the website "Space Weather: What impact do solar flares have on human activities?", the effects that do affect us are:
Disturbance of the ionosphere, disrupting radio communications.
heating, hence expansion of the atmosphere would cause drag on satellites, degrading their orbits, also affecting the accuracy of GPS.
From the Solar Weather site, an important distinction between CME's and solar flares in how they affect the Earth:
Coronal mass ejections are more likely to have a significant effect on our activities than flares because they carry more material into a larger volume of interplanetary space, increasing the likelihood that they will interact with the Earth. While a flare alone produces high-energy particles near the Sun, some of which escape into interplanetary space, a CME drives a shock wave which can continuously produce energetic particles as it propagates through interplanetary space. When a CME reaches the Earth, its impact disturbs the Earth's magnetosphere, setting off a geomagnetic storm.
Very severe CME's can also potentially disrupt power grids and communications.
The following are largely excerpts from an answer I wrote at https://physics.stackexchange.com/a/258093/59023.
What are the main differences between solar flares and coronal mass ejections?
There are several differences between solar flares and coronal mass ejections (CMEs), the latter of which involve large amounts (i.e., upwards of billions of tons) of matter (in the form of plasma) to leave the sun.
A solar flare is really described by the sudden enhancement of x-rays from a small region in the solar corona. They can produce streams of high energy particles, called solar energetic particles or SEPs (CMEs can produce SEPs as well), but these are streams of magnetic field-aligned particles propagating away from the sun. They can have energies up to ~GeV for ions and several ~MeV for electrons, but rarely higher. Earth's atmosphere does a great job of shielding much of this and the surrounding magnetic field helps to "deflect" some of the incident particles as well.
A CME, on the other hand, expands nearly as fast as it propagates which means their radius of curvature by the time they reach Earth is nearly 1 AU. They are, in effect, a large "magnetic piston" (sometimes called a magnetic cloud or flux rope etc.) that piles-up plasma on their leading edge and can produce rather strong collisionless shock waves. The magnetic field orientation of the magnetic piston is very important, as its orientation relative to the Earth's magnetic field can result in either a small auroral response or a major geomagnetic storm.
...what causes them...
Both are thought to ultimately arise from a process called magnetic reconnection -- a process that results in a reconfiguration of the magnetic field topology and transformation of magnetic energy into bulk particle kinetic energy.
In the case of flares, reconnection results in jets of highly energetic electrons and protons that slam into the upper solar atmosphere resulting in x-rays produced by thick target Bremsstrahlung radiation.
In the case of CMEs, reconnection results in a release of a massive amount of plasma often confined within a magnetic cloud.
...what sort of damage can they cause...
...what are the differences in their composition?
As I explained above, flares are just enhancements in x-rays so there is no composition. CMEs generally have different charge state and heavy ion composition than the nominal solar wind.