Let's start with what happened directly after World War II. Japan fell directly under US occupation and several policies were pushed by the offices of the Supreme Commander for the Allied Powers (SCAP) headed by McArthur.
Among these policies were things such as disarmament, de-industrialization, enforcing strong media controls, and of course, overseeing martial law.
The key thing for us to discuss here is the control of media. The main control enacted was censorship of specific topics that SCAP deemed disorderly or directly contradictory to their aims. Thus banned were things such as criticism of Allied soldiers, the occupation itself, discussing censorship, discussion about the bombs dropped on Hiroshima and Nagasaki, prostitution, gambling, smuggling, praising the old regime, praising Nazi/Communist/monarchial governments, propaganda in general, fraternization between Japanese women and occupation soldiers, famine, and most importantly for our purposes praising war criminals.
Besides these topics, the media was actually allowed a relatively free hand to discuss a variety of topics and this level of freedom had not been enjoyed by the Japanese press and publishers since the war started. This ban not only covered journalists but also book publishers, plays, songs, etc. All forms of media were categorically watched for violations of these topics.
So starting from the very end of World War II, it was literally illegal for Japanese media to defend war criminals (albeit by command of an armed occupying force)
But while interested parties might have railed against this, the general public mood didn't need to be persuaded by the law. The vast majority of Japanese citizens had long become weary of war and many blamed the militant leadership that led them into such a disastrous series of events.
By the end of the conflict, Japan proper had been horribly scarred by the most thorough bombing campaign the world had ever witnessed at that point in time. Cities were devastated, infrastructure had been pounded to dust, and every part of Japan was strangled by the iron tight blockade. Those who were not dead or maimed were often homeless and on the brink of starvation.
This did not engender a great deal of support for Japanese leadership at the end of the war and convicted war criminals were often subject to the derision of the Japanese public.
It should be noted that the widows and family of Japanese servicemen and women who fell in the line of duty were due awards as well as stipends from the government, to show that their sacrifice was duly observed and recognized by their nation.
The families of war criminals got nothing. Legally speaking, by the power of the Japanese government, war criminals (though convicted by military tribunal that was outside the jurisdiction of the Japanese judiciary) were stripped of their rank and their service was not recognized, essentially having died ignominious deaths and treated no different from a criminal who had been convicted of a capital crime in the Japanese legal system.
Directly after the end of WWII, the Occupation authorities, Japanese officials, and the Japanese public generally all agreed on harsh punishments and repudiation for convicted war criminals.
How did this change so drastically?
Fast forward several years to the 1950s. SCAP and the Occupation are gone and Japan is a sovereign nation again, just starting to really make some headway in recovering from the destruction of war. Meanwhile, the Cold War is blowing up. The Korean War had just begun and UN coalition troops had fought toe to toe with the PRC and North Korea, seemingly the vanguard of a rising red tide of Communism that was threatening to swallow Asia.
Japan was feeling a lot of pressure from the US to crack down on any kind of 'red' sentiment. Japanese people themselves were slowly building up to their own 'red scare'. The government subsequently started a large scale campaign to suppress freedom of speech, freedom of press and control information and political dialogue. Worth noting here that the Japanese Communist Party, which was legitimized under the US Occupation (they were in hiding during their existence under the Japanese Empire), was now persecuted incessantly, partly due to the anti-Communist stance of the US.
Moving on, I'll mainly focus on the effects this stance shift had on education. The Japanese government began a campaign of banning books, especially textbooks that seemed to support communist viewpoints, which included content that showed the Japanese working class as suffering or oppressed, lack of political freedom, encouraging questioning central authority, as well as any books that even remotely supported anything related to the Soviet Union or the PRC.
Consequently, this meant that any books that condemned the Japanese Empire for its actions during World War II were heavily suppressed.
Scholars and academics were heavily targeted,, of course, while newspapers and media outlets were co-opted into the information control scheme, for the sake of national order—and all justified because of the perceived looming threat of violent Communist revolution and invasion feeling very real at the time for many Japanese citizens.
Funnily enough, part of these events are due to the fact that the US was so adamant on building up an anti-Communist ally in Asia. The Japanese government had free reign politically to crack down on labor movements, political expression, and academic learning/research, all in the name of fighting the Communist threat.
Directly after World War 2, the Japanese education system went under a number of reforms, many of which were focused on cultivating critical thinking through group discussion and teaching the method of self study (teaching students how to learn instead of rote memorization—a gross simplification but we'll need to cut some corners here).
But this changed very quickly as American strategic concerns overruled the progressive educational reforms of the late 1940s and we move into the 1950s.
Education changed very quickly, with the banning of hundreds of books and almost seeming to return to war time education. Political hardliners rejoiced at the apparent return to fundamentalist education.
Elementary schoolers curriculum required teachers to teach students to hold favorable views of the Emperor, as in pre-war years. Middle school teachers didn't need to teach World War II at all, simply that a war had occurred and post-war reconstruction, with a focus on the efforts of a patriotic, united citizenry that made rebuilding possible. Highschoolers only needed a 'recognition...of the importance of avoiding wars'.
Now, these education standards would be unthinkable today and would cause massive controversy in modern times in Asia. So why was this even considered back in the 1950s?
This happened entirely because of Cold War adversarial politics.
With much of Asia seemingly falling to Communist forces, there was very little political value put in reconciliation. China was militant and aggressively pursuing a doctrine of violent Communist revolution in the region. Korea was war torn and half of it was controlled by an adversarial regime. South East Asia had swarms of Communist militias if not out right revolutions.
Japanese politicians simply didn't care. More importance was put in inspiring patriotism and convincing the people of the Communist threat while extolling the superior virtues of the capitalist system. Education was more about preparing the citizens for ideological warfare than critical thinking.
Speaking about the politicians that created this educational policy, many of these politicians were solidly right-wing and supportive of honoring if not glorifying the venerable statesmen and military leaders of Imperial Japan. Many of them had actually been purged by the American occupation but were reconciled and reintegrated because their staunch anti-Communist views made them desirable for American interests in the region.
Unfortunately, these politicians are the origins of political historical revisionism and academic repression. For example, in 1957 under the authorization system that was first installed during the US occupation, 8 middle school textbooks were banned. The contents of the books were fairly graphic and very anti-war, detailing the many atrocities and war crimes Japan had committed in the war.
They were labeled and politically dangerous and harboring Communist sentiments, and subsequently banned.
During this time period of heavy academic suppression, many gave up writing textbooks at all. Some historians even stopped publishing and working on research because they kept coming up against the government roadblock every time.
But there were those who were vehemently opposed to these restrictions. Ienaga Saburo was the most well known figure for this. He brought multiple lawsuits against the Japanese government, claiming the censorship was a violation of the Constitution.
It's also important to note that at the time (1950s), the general mood of the Japanese people was extremely anti-war, anti-establishment, and anti-military. Part of the almost ironic educational reforms of the 1950s (in some respects seemingly returning to pre-war and wartime education) was to try and reverse this public sentiment that was seen as politically conducive to Communist and revolutionary feelings.
(Cont'd)
Followup: to what extent has Japan apologized for Nanking?
As a follow up to AsiaExperts excellent answer, why didn't the same thing happen in Germany, as contrasted by OP's question?
Why didn't anti-communist US influences in West Germany lead to a similar quasi acceptance of right wing politics? What was different about the early rebuilding efforts and education, especially in regards to censorship, which seems to have played a large role in Japan's postwar culture?