Mussolini was an incredible opportunist and the pivot to Germany was due a changing political situation.
The first reason concerned the Italian region of South Tirol, a predominantly German speaking region that by all the rhetoric of Hitler was to be part of the German Reich. This was one of the major reasons that prompted the Italian stance in Hitlers first Anschluss. The second attempt was accompanied with a German guarantee that South Tirol was not to be part of the Third Reich.
The second reason was that Mussolini had from 33 onward had made it clear to the UK and France that he was willing to maintain the status quo in Europe. In exchange for this, he wanted to have a free hand in Africa along with some border corrections and ceding of colonial possessions. He got the French to give him a free hand in Abyssinia. When that invasion took place however, the League of Nations passed a series of symbolic embargoes, where any real economic hurt was avoided due to very heavy French pressure, which hoped to keep Italy part of the Stresa front, a three-way alliance between France, Italy and the United Kingdom. For instance, sanctions included the banning of aluminium to Italy, one of the few materials of which Italy produced a surplus. Likewise the sale of war critical resources such as oil was left mostly alone.
With the League condemning the invasion the Germans vocally supported the Italian invasion and supplied Italy with some materials that were cut off.
Between returning a favor and the Guarantee meant that the original reason for an independent Austria, to function as a buffer between Italy and Germany was now gone, and as such, Mussolini had no issues giving it up, which in turn cemented the Axis marriage (although it would be a rather unhappy one)