An Abwehr question, finally! I will preface this by saying it's been about six years since I was really looking at Abwehr stuff, but the organization has remained one of my interests.
So, why was the Abwehr anti-Nazi? Two things of note underly this entire discussion. The first is that intelligence, at least in the perspective of the German military, had always occupied a sort of fringe position with military culture and heirarchy, up to and throughout the Second World War. According to Richard Bassett's book Hitler's Spy Chief: The Wilhelm Canaris Mystery, the Abwehr met with disdain from the vast majority of the Reichswehr after its creation as most officers felt that the nature of intelligence work went against the very heart of Prussian military ideals. This is an important aspect of the Abwehr to understand, as its status as a fringe element of the military made it a very good place for anti-Nazi sentiment to develop. It naturally attracted officers who were outside the mold of acceptable military standards and practice, meaning that it was an excellent breeding ground for contrarianism. The second thing of note is the second commander of the Abwehr, prior to the famous Canaris, was a naval captain named Conrad Patzig. He was placed in charge of the organization as it was expanding in the early 1930s. Patzig was a very traditional naval officer with a very blunt attitude and a blatant dislike of the Nazi party. Despite a lot of successes in terms of expanding the Abwehr's power, he eventually clashed with Heinrich Himmler (and to a certain extent Hitler himself) over intelligence operations and was shuffled out by Reinhard Heydrich, head of the SD (SS intelligence agency). Heydrich replaced him with a personal friend, one-time mentor, and long-time rival: Admiral Wilhelm Canaris. The important takeaway here is that, even with Canaris' anti-Nazi sentiment, the organization had already spent a few years under the guidance of a man who disliked the Nazis. In other words, the stage was perfectly set for Canaris to mold the organization into an anti-Nazi agency within the heart of the Third Reich.
Here's where we get to the answer to your first question: The reason the Abwehr was anti-Nazi was because its commander, Wilhelm Canaris, was anti-Nazi. Canaris, according to Bassett, had initially started out sympathetic to the Nazi regime, being a staunch traditionalist Catholic and a proud anti-Bolshevik. But, as the Nazis power grow, Canaris' opinion quickly turned to outright loathing. According to Jefferson Adams, in 1937, shortly after taking command of the Abwehr, Canaris remarked to his predecessor Patzig that the Nazi regime was made up entirely of, "criminals who would bring Germany down." Canaris' anti-Nazi sentiments (and, admittedly, a penchant for supporting malcontents and contrarians), led him to morph Germany's largest intelligence agency into an anti-Nazi haven. Under the auspices of his office, he provided security for anti-Nazi advocates such as General Hans Oster, who was emerging as one the key resistance members against Hitler in the German military. As part of his reforms, Canaris also sponsored a significant recruitment push to get new assets for the Abwehr, and according to Lauan Paine's book German Military Intelligence in World War II: The Abwehr, he intentionally went out of his way to recruit individuals who were not Nazis and/or who had specific grievances against or doubts about the regime. By the start of World War II, the vast majority of Abwehr Sections (equivalent to branches) were under the command of anti-Nazis thanks to Canaris' machinations and personal selections. These included Chief of Section I Hans Pieckenbrock, Chief of Section II Erwin von Lahousen, Chief of Central Section Hans Oster, Chief of Section III Franz-Eccard von Bentivegni (who was quietly anti-Nazi), Chief of Ast Prague Paul Thummel (a Czechoslovakian double agent no less!), Chief of Ast Paris (the French branch) Friederich Rudolf, Chief of Ast Madrid Gustav Lenz, Chief of Ast Italy Otto Helfferich, the Head of the ZB Foreign Politics unit Hans Dohnanyi, and most others. In short, Canaris had ensured that almost every senior official within the Abwehr organization was either quietly or openly anti-Nazi. This would not really have been the case without his influence, even if the Abwehr was a fringe group. Furthermore, most of these men were loyal to Canaris and/or close personal friends with him. He trusted them implicitly, enough that he felt comfortable expressing anti-regime opinions in their presence, and they returned the favor. Canaris was fostering his own personal bitterness against Nazism while at the same time enabling it in others. Canaris' even extended his anti-Nazism to using Abwehr assets to enact plans and operations meant to befuddle and defy the regime. For example, alongside Hans Dohnanyi, he helped numerous Jews escape Nazi persecution by making them agents of the Abwehr. Indeed, by the time of the invasion of France, Oster, Canaris, Lahousen, and Dohanyi were all members of the Black Orchestra military resistance collective against Hitler. Canaris ingrained so far as to ingrain himself in negotiations with Spain in order to meet with Franco and convince him not to side with the Nazis (Franco trusted his opinions as they were personal friends dating back to Canaris serving as a spy in Spain during the First World War). He even attempted to negotiate an early peace agreement with the Americans behind Hitler's back. Clearly, given Canaris' dedication to opposing the Nazi regime and his extreme control over his organization, it's not surprising that the Abwehr became a nest of vipers clutched to the breast of Nazi Germany.
So, on to your second question, why was the Abwehr allowed to keep going despite its anti-Nazi sentiment? This is a good question and sort of hard to answer in a way, because there's no real tangible explanation easily available. Part of it certainly stems from the fact that Canaris, while vigorously anti-Nazi, was incredibly careful about exposing his sentiments. Per Adams, Canaris, despite being involved in the Black Orchestra, always kept his distance from the other non-Abwehr plotters, never fully committing himself to the inner circle. As such, the Gestapo was unable to generate much evidence directly indicting him for treasonous activities, despite having much circumstantial evidence that he was playing a dangerous game. Indeed, Canaris made a point of only fully trusting those who's loyalty he could absolutely guarantee, something that made him (and by extension the Abwehr) very hard to reach. Canaris' network of contacts and organizations was also incredibly valuable to the German war effort (despite the Abwehr's generally poor performance), thanks largely to his own personal charisma, so removing him from power would have also negatively impacted the course of the German war effort far more than what Heinrich Himmler believed Canaris was up to. Certainly, the Abwehr, as the leading intelligence agency of the Reich, was still viewed as providing a valuable service even if it was on the fringe of accepted political standards and led by a strange, reclusive man. Simply put, kneecapping your key intelligence organization in the middle of a war is not usually the best way to go about winning one, especially if you don't have to, and those involved in such decision making knew that. As has previously been noted, the Abwehr was already considered an odd group, so the fact that so many "odd" people ended up there may not have really caused too much unease. Additionally, Canaris personally was quiet and reserved in most cases and has been described as an enigma of a man. In other words, a person who could mask his intentions well, to the point where someone deciding whether or not it was worth it to remove him might think twice because of the potential embarrassment and political backlash if he did prove loyal to the cause. It is said that Canaris also handled Hitler very well most of the time, flattering him during meetings and generally acting supportive of his requests. This too, contributed to his protected status and, by extension, the continued protection of the Abwehr and its agents. So, though nebulous, the answer to your second question is: A mixture of Canaris' personal ability and charisma, military necessity, and tightly-knit organizational loyalty.
Obviously, these protections didn't hold out. When the July Plot failed , the members of the military resistant to Hitler, including those within the Abwehr, were rolled up by the Gestapo. Canaris himself was arrested, meaning his protections could no longer extend to his subordinates. Interestingly, according to Adams, the only reason Canaris was really brought down was because his personal diaries were found after his initial arrest. A remarkable slip up for such a careful man. He was executed in Flossenburg in April 1945, after months of torture and a brutal show trial. It's worth noting that, despite all the beatings, starvation, humiliations, and months of solitary confinement, Canaris never gave up a single name to his interrogators. Oster, Dohnanyi, and Deitrich Bonhoeffer (another anti-Nazi Abwehr agent) were also executed around the same time. Leopold Burkner, Chief of Abwehr Foreign Section and one of the few Abwehr officers sympathetic to the Nazi cause, was put in charge of a significantly reduced agency after Canaris' arrest and served in that position until the end of the war.
Sources
Richard Bassett, Hitler's Spy Chief: the Wilhelm Canaris Mystery
Paul Leverkuehn, German Military Intelligence.
David Kahn, The Final Solution of the Abwehr
Lauran Paine, German Military Intelligence in World War II: the Abwehr
Jefferson Adams, Historical Dictionary of German Intelligence
Wilhelm Canaris on the Jewish Virtual Library, http://www.jewishvirtuallibrary.org/wilhelm-canaris