First off, why were they targets? Was it because they were western Christian countries attacked because of their freedom (as so claimed here by political pundits)? In a word, no. They have also conducted attacks in non-Christian countries like Beirut  and Ankara , so just because they are predominantly Christian countries does not explain their motive (at least in full). Shortly after the attacks in both Paris and Belgium, ISIS released statements explaining their motive.
Concerning Paris, they said that it (and all nations following their path) will remain on the target list “as long as they partake in the crusader campaign [international coalition], as long as they dare to curse our prophet (peace and blessings be upon him), and as long as they boast about their war against Islam in France and their jets strike against Muslims in the lands of the Caliphate with their jets.” 
Concerning Belgium, they said “We promise black days for all crusader nations allied in their war against the Islamic State [including Belgium], in response to their aggressions against it.” 
Simply put, they attack us because we attacked them. On face value, this does seem to have Quranic justification when it says “God does not enjoin you from befriending those who do not fight you because of religion, and do not evict you from your homes. You may befriend them and be equitable towards them. God loves the equitable.” 
But even so, the next verse shows a stern warning against those who aggress against the Muslims, saying that “God enjoins you only from befriending those who fight you because of religion, evict you from your homes, and band together with others to banish you. You shall not befriend them. Those who befriend them are the transgressors.” 
I am no Islamic scholar, so I will not say anything else on the theological side of things. This is best for the scholars to deal with, not me. Nonetheless, the potential for a truce with ISIS, such as the truce that the early Muslims had with the Meccans in the Treaty of Hudaybiyyah has been considered by ISIS themselves.
In issue 12 of ISIS’s English language magazine, Dabiq, one author asked the audience a speculative question, “Will the West abandon its support of the Rāfidah, the murtadd tawāghīt, and the Jewish state? And will the intervention of Russia in favor of Iran in Shām and Iraq lead the West into a truce with the Khilāfah? All one can say is that Allah knows best.” 
Even John Cantlie, the well-known British hostage/reporter for ISIS said in the sae issue of Dabiq “The Islamic State holds the “international system” to be a tāghūt, something evil enforcing manmade laws upon people. It will never “learn” to “work” with it. But a truce with Western nations is always an option in Sharī’ah law. […] if Western nations want a truce, they really should think thrice before throwing away the chance.” 
Second question, could we have stopped both of the attacks on Paris and Brussels? Whether or not starting the international bombing campaigns on ISIS in the first place would have led to the attacks never carried out in the first place is an issue that takes more guess work rather than practicality. Instead, I’m going to go for the practical question of “Could it have been stopped?”.
The short answer is, yes, it could have, both the attacks in France and Belgium could have been stopped. Days after the Paris attacks in November, the Associated Press reported that “Senior Iraqi intelligence officials warned members of the U.S.-led coalition fighting the Islamic State group of imminent assaults by the militant organization just one day before last week’s deadly attacks in Paris killed 129 people”  Even though the specifics of the attack were not mentioned in the Iraqi dispatch to French intelligence, it still gave them some sort of ground to cover. 
Even then, France had several clues that ISIS fighters were headed to Belgium to plan and latter carry out terrorist acts in Paris. In January 2015, Turkish authorities detained Brahim Abdeslam, who eventually blew himself up at the Comptoir Voltaire restaurant ten months later, and deported him to Belgium. With scant evidence of their own, Belgian authorities released him. 
Still, France had, since 2010, a State Security file for Ismail Omar Mostefai, who would eventually detonate his explosive vest inside Paris’ Bataclan concert hall. Turkish police also wrote to Paris about Mostefai in December 2015 and June of 2015, both of which went unheeded by French authorities. Yet still, another attacker missed four weekly check-ins with French police in 2013 before they issued an arrest warrant against him. Bilal Hadfi and Sami Amimour were also at one point under surveillance. 
Former technical director of the US National Security Agency William Binney testified before a British parliamentary committee that intelligence agencies are missing important data on terrorist attacks because they are overwhelmed with electronic data. “They could have got all that data up front with a targeted approach, and they could have had the opportunity to stop them before the attack”, Binney said.  Jesper Lund, chairman of IT-Political Association of Denmark, also testified to the same committee, giving the case study of Denmark utilizing the same method of bulk data collection a decade ago, only to stop using seven years into the program because they “concluded that internet connection records were not useful for law enforcement work.” 
In other words, the problem “is not a lack of data, but a failure to act on information authorities already had. In fact, indiscriminate bulk data sweeps have not been useful.” 
Even so, public controversy has shifted to the supposed problem of encryption, but the evidence doesn’t pile up. The Intercept notes that “news emerging from Paris, as well as evidence from a Belgian ISIS raid in January, suggests that the ISIS terror networks involved were communicating in the clear, and that the data on their smartphones was not encrypted. […] Le Monde reported that investigators were able to access the data on the phone, including a detailed map of the concert hall and an SMS messaging saying “we’re off; we’re starting.” Police were also able to trace the phone’s movements.” 
Furthermore, “court records and public accounts have detailed how earlier operatives sent to Europe in 2014 and early 2015 made phone calls or sent unencrypted messages that were intercepted, allowing the police to track and disrupt their plots.” 
A somewhat similar case happened in Belgium, missed clues, and therefore missed opportunities. Belgian authorities have been looking for two of the attackers, Ibrahim and Khalid el Bakraoui, months before the Brussel attacks. A red notice from Interpol even went out to seek the arrest of Khalid on terrorism charges back in December and Ibrahim on suspicions of criminal activity.  Ibrahim el Bakraoui was even deported after caught by Turkey near the Syrian border, who promptly told the Belgians that he was known for criminal activity. Former CIA analyst Aki Peritz, said, “Obviously it turns out that he was a hardcore jihadist. The fact that they’re not sharing the exact information and have the laws to actually put these guys in jail suggests that there is a huge miscommunication between intelligence agencies between law enforcement.” 
But the even bigger shocker is that both of them were supposed to be in prison for the past several years. Back in 2010, Ibrahim was sentenced to nine years in prison after engaging in a shootout with police officers. He was released early but then violated his parole, guaranteeing more prison time. Khalid, on the other hand, got five years in jail in 2011 after a series of car thefts. 
Israeli new outlet Haaretz reported that Belgian and Western intelligence officials had advance and precise warnings about the planned attacks and knew with a high degree of certainty that attacks at the airport and subway were planned for the very near future.  So why didn’t they act on it? In this case, I don’t know. Belgium has been controversial, from what I understand, for not having the same kind of security and intelligence measures of other Western nations, like the U.K. and USA do.
The answer might lie, in part, of the unwillingness of sharing information. Eelco Kessels, London Office director and senior analyst for the Global Center on Cooperative Security noted that “This is a classical case where we see the importance of intelligence cooperation not just internally but externally. The most headway on this front is still made by bilateral or multilateral cooperation between countries.”  But he also forewarned that “European nations have often been unwilling to freely share intelligence with one another unless there is the promise of getting something in return. This back-scratching approach to intelligence across European borders, he said, has slowed progress in fighting terrorism in the EU.” 
Lastly, what can we do about it? I go back to both of my other points when I formulate a conclusion to this. First off, a more targeted approach of intelligence data that (a), does not violate the 4th Amendment and (b), does not gather too much data to sift though.
Secondly, the immediate halt of our support for the dictators of the Middle East and covertly (or overtly) supporting groups that eventually turn their back on us (the mujahedeen from Afghanistan in the 1980s comes to mind), or what I dub as one of the prime radicalization factors. Although this won’t guarantee at first the stopping of terrorism against the U.S., this is a prime factor that can cause its overall decline.
This is a borader topic for another time, but Sheldon Richman somewhat sums it up when he wrote an article for Reason the other day. “It’s not hard to fathom why the full story of terrorism is not acknowledged by officials and pundits: it would draw attention to what the U.S. government and allied states have long been doing to people in the Muslim world. Nearly all Americans seem to think it’s a sheer coincidence that terrorism is most likely to be committed by people who profess some form of Islam and that the U.S. military has for decades been bombing, droning, occupying, torturing, etc. in multiple Islamic countries. Or perhaps they think U.S., inflicted violence is just a defensive response to earlier terrorism. When the U.S. military isn’t wreaking havoc directly, the U.S. government is underwriting and arming tyrants like those in Saudi Arabia, Egypt, and elsewhere. And just to complete the picture, the U.S. government fully backs the Israeli state, which has oppressed Palestinians and occupied their land for many decades.” 
He has also penned another article that gives a broader overview if any of you are interested.
: ISIS Statement on Paris Attacks
: ISIS Statement on Belgium Attacks
: Quran 60:8
: Quran 60:9