It's hard to arrive at anything close to a comprehesive answer to this question, because there are so many different factors at play. I can give a very broad-strokes overview, but I'm happy to answer any more specific followup questions you have.
So, in not-very-brief, two meta-reasons the Axis lost the intelligence war:
The overall weakness of the Axis intelligence services: the German counterintelligence and internal security apparatus (the Gestapo and SD) were highly effective. But their foreign intelligence service was decidedly anaemic: the vast majority of foreign intelligence operations were carried out by the military intelligence department, the Abwehr, which proved to be far from a world-class intelligence agency. The SD's foreign department, the Ausland-SD, achieved relatively little of note.
In other regards (most particularly signals intelligence and cryptography), it was decentralisation and a lack of top-level command, control and coordination that was to prove their undoing. So for example, the Germans had no central codebreaking and signals intelligence agency; compare and contrast with the UK, where you had a centralised effort (including codebreakers from around occupied Europe) to penetrate German communications.
Japanese intelligence suffered from much the same malaise: like the German intelligence establishment, it was fragmented and decentralised across departments and military commands, and after experiencing some early success struggled to develop any effective capacity for large-scale intelligence gathering.
Ultimately, neither German nor Japanese intelligence were able to establish and maintain any kind of substantial foothold inside the UK or US — and as far as the intelligence war goes, that's the whole ballgame.
Highly aggressive Allied intelligence services: on a couple of different levels, the Allied approach to wartime intelligence was remarkably bold. The first and most obvious is that both the UK and US possessed well-established and highly capable counterintelligence services (the Security Service and the FBI, respectively.) The success of the FBI in foiling such attempts as were made to infiltrate the mainland US post-1941, and the implausible success of MI5 in operating the Double-Cross system meant that Axis spies were for the most part either detained shortly after their arrival — or turned and run as double agents.
The second factor is that both the UK and US showed a willingness to take an unusually experimental approach to the intelligence war overseas: in the UK, the Special Operations Executive was a distinct departure from how British foreign intelligence had operated to date; in the US, the establishment of the Office of Strategic Services represented America's first attempt at a standalone professional intelligence agency. Both organisations were highly unorthodox, with a strong focus on developing new modes of irregular warfare which proved highly effective. Not only that, but (as discussed briefly above) their well-organised SIGINT efforts gave them access to a pipeline of timely intelligence which allowed them to reap significant strategic rewards.
The Soviet Union, meanwhile, is a whole other kettle of fish I'm going to steer clear of for now, because this is already a long answer and it's super complicated. The short version is: the Soviet intelligence war was primarily waged against its ostensible allies in Britain and America, rather than against Germany.
Here's very brief and totally non-canonical intelligence history reading list:
In response to a deleted comment: There was a commercial variant of the Enigma used by the Germans and freely sold. The poles purchased this variant and the military Enigma wasn't too different.
http://chris-intel-corner.blogspot.gr/2014/07/case-wicher-information-from-war-diary.html
An interesting exception to the pattern is the Netherlands. The entire British network was infiltrated and then subsequently run by the Germans.
You can read the German side of this story in London Calling North Pole by the guy who ran the German side: Hermann Giskes.
You can also read part of the British side in Between Silk And Cyanide, which are the memoirs of the SOE codemaker who worked out that the Germans must have been running the agents.
Many questions are not answered there, though, such as: why did the British keep the network intact even when they knew it must be blown? Why did they continue dropping agents and equipment directly to the Germans?
I am unsure if these really count as proper historical sources, though, so sorry if this doesn't technically count as a proper top-level answer.
Aside from the funkspiel the Germans pulled off in Holland - ably chronicled in Leo Marks' book - it's worth mentioning an earlier British failure in that same country, the Venlo Incident, in which two British intelligence agencies were lured to the border and simply snatched by a German strongarm squad. The November 1939 incident was such a disaster that it may be credited as a wake-up call for the British. Somewhat surprisingly, one of the two kidnapped officers survived the war in a concentration camp.
There are many reasons but I'll mention one I haven't seen covered in other comments:
Allied intelligence agencies had the advantage that Germany had invaded and occupied territory; finding people within those territories to assist the cause was far easier than Germans trying to infiltrate unoccupied UK or the US.
The Allies could reliably expect to receive information from Dutch, German, and Polish double agents, and anti-Nazi operatives were not unknown, particularly among Austrians who had opposed annexation.
Compared to the Germans, the Allies simply had more sources of information.