I understand that the Japanese still have an army but its a territorial only.
It wasn't allowed, it was necessary.
Shortly after WW2 it became obvious that the alliance with the Soviets was over and that Stalin might invade the rest of Europe.
German chancellor Konrad Adenauer was in charge from 1949 till 1963 and it was very important to him that the newly created Federal Republic of Germany got the protection, trust, safety and support from the western allies so that the survival of Germany is secured. Even if it meant to give up East Germany to achieve that - and even if it meant to build up a new army.
Losing a part of Germany to the communists seemed to be better than losing all of it.
The USA simply needed much more troops to be able to (maybe) defend Europe against a potential Soviet attack and Germany would be the very first line of defense. Germany was expected to do her part in "defending freedom" etc.
So Adenauer and his administration agreed to build up a new German army, even though wide parts of the German population (and of course the oppostion in the Bundestag) didn't like the idea. In return, the Adenauer administration demanded full sovereignity for Germany and got it (well, most of it).
Post-War Japan was, as described by historian John Dower, an experiment. The country of Japan and its society were to be built from the ground up. The Americans were committed to removing all traces of militarism and expansionism from Japanese society and culture. So really there were two main reasons why having the Japanese build up an army wasn't in the American's interest. It was thought that allowing Japan to have an army would encourage militarism and lead to a strong, reactionary, military faction in Japanese politics. The Americans had spent so much time and effort trying to rid Japan of this exact thing, so they didn't want to risk giving Japan an army and undoing all the work they did building Japan into a peaceful, democratic society. Secondly, Japan was under no military threat, at least not from the ground. America had unrivaled naval superiority, especially in the Pacific, so Japan was under absolutely no military threat.
Now Germany had also had its military dismantled and the allies went to great pains to remove German militarism like they had done in Japan. However, as early as 1950 the allies were relaising that the numerical superiority of the Soviets and the Warsaw pact posed a serious danger to western Europe. The allies could not hope to stop the Soviet juggernaut whose occupation forces dwarfed those of the western allies. Konrad Adenauer began to negotiate with the Americans about allowing West Germany to form a new army (Adenauer hoped having an army could assert German independence and allow the Germans to defend against the growing Soviet threat). The allies agreed that the Soviets were a far bigger threat than a revived German army and so they approved. Now the new German army, formed in 1955, did have restrictions placed on it, the allies also made sure that the German army was placed firmly integrated with Nato.
Sources:
Embracing Defeat by John Dower
Reforging the Iron Cross by Donald Abenheim
In the years directly following the end of the second world war, West Germany did not have any armed forces. For almost ten years, the security of Germany was in the hands of the major powers, US, Uk and France in the west and the Soviet union in the east.
In 1949, the two Germanys became independent, but it wasn't until 1955 that West Germany was allowed to raise an army. Initially, France opposed this arrangement, having been invaded by Germany twice that century. France instead sought another solution, the European Defence Community, which intended to integrate the militaries of France, W.Germany, Italy and the Benelux countries.
As a result of the Korean war, West-East tensions grew, and the failure to bring the European defence community from the paper into reality failed. In 1954, France ceased opposition to W.German rearmament and supported their accesion into NATO.
So, in late 1955, West Germany officialy founded the Bundeswehr (lit. Federal Defence ). East Germany formed their alternative, the NVA (Nationale Volksarmee, National Peoples army) in 1956. As the cold war went on, these armies would grow in both size and importance.
The Japanese most certainly were. In the sense that the Japanese were blocked from forming an army, so was West Germany for a good decade after the war. Not that they really had the means to buy, let alone manufacture and field the means to pose a real threat.
The overarching difference was that the US needed a more mobilized West Germany to help pose as a deterrent to Soviet action, where as Japan would have been fairly easy to defend against any communist action. As it were, after WW2 the US didn't have the world's best by any metric in terms of boots, treads, and tires on the ground, but they most certainly had a capable air force, and by far the largest blue water fleet.
The Soviets wouldn't have even had the means to properly get boots on the ground in Japan, and keep them supplied. To say nothing of having to haul an army all the way to the Pacific Seaboard, get it across the ocean to Japan, and then invade a large, mountainous island.
Well to be picky, the Germans weren't allowed to keep an army after WWII.
The German armed forces were demobilised from mid-1945, and a series of Control Council instruments decreed a process of demobilisation (Directive No.18 12 November 1945), the abolition of military training and education (Law No.8 30 November 1945), bans on the display of military uniforms, insignia, banners and so on(Order No.1, 30 August 1945), and finally the abolition of the institutions of the armed forces themselves in Law No. 34 (20 August 1946)
The Basic Law of 1949 included a similar article (Article 89 I believe) concerning armed forces and the use of military force, although less explicitly strict.
West Germany was permitted to begin re-arming in 1955 only after the failure of the European Defence Community, and with clear guarantees to its allies that the force was only to be for national defence. The Bundeswehr has incredibly strict civilian control imposed on it, and requires specific permission from the Bundestag to be deployed outside Germany - which is usually provided with strict rules of engagement and maximum force limits.
Summary - neither the Germans or Japanese were allowed to keep an army as such, their armed forces were demobilised, abolished and constitutionally restricted in the future. From the 1950s in response to international security concerns, both were permitted to begin having armed forces again, although Japan's were and remain de facto as they not outwardly official armed forces.