There were a number of reasons why Japan, Italy, and Germany were allied during World War II. Many of the factors that convinced Japan to become part of the Axis alliance had their origins in places other than Europe. However, if we look at the events from a European perspective, perhaps the following factors can be considered
Both Germany and Japan had the goal of territorial expansion on their respective continents. The Soviet Union was an obstacle to this goal and a common enemy for both Japan and Germany as it lay between them. The old saying goes that "the enemy of my enemy is my friend." On November 25, 1936, Japan and Germany signed a pact against the Soviet Union. Italy joined the pact one year later. This was part of the basis of the Axis alliance.
When Japan attacked the United States at Pearl Harbor in December 1941, the United States had been providing material aid to Great Britain in the form of the lend-lease program. As such, Germany saw the United States as an enemy as well and also declared war on the US. Here we have another common enemy situation.
When Japan joined the conflict at the end of 1941, it had no intention of fighting in Europe itself. Japan was focused on securing an Asian and Pacific empire. However, the many military successes of the other Axis powers on the continent of Europe convinced Japan that it was on the winning side. The Axis powers were convinced that the war would be over shortly as Great Britain stood alone and isolated in Western Europe and Germany's armies were successfully pushing deep into the Soviet Union. By being part of the Axis alliance, Japanese leaders predicted that they would soon emerge as some of the leaders of a new powerful world order.