It helps, for the sake of discussion if nothing else, to seperate the dogma that is fed to the rank and file terrorists, with the actual goals of those in power. The dogma is simplistic, easy to consume propaganda that merely paints everything as them vs us, and us as the source of all ill in their society. It's crude, simple, and effective, and we've seen it used in countless governments, including our own during the Red Scare, for centuries. Add in a bit of religious devotion and fanaticism, and it becomes child's play to convince an angry young man to strap a bomb to himself to kill the devils in men's clothing.
The actual ringleaders however, are more nuanced than that. While I won't speculate on the exact goals of the leaders of ISIS, they generally can be boiled down to control. They want control and autonomy of the territory they occupy. They want power and control over those under them. So on and so on. Failings on the home front can easily be spun into morale successes by "striking back" against the enemy on their home turf. It's not random senseless violence to them, it's a sort of cold calculation. Every attack they perpetrate strengths their power base, and buys them political power inside the organization's structure.