Italy's allegiance in World War I shifted dramatically. It began the war technically allied to Germany and Austria-Hungary but ended up fighting against them.
Italy joined Germany and Austria-Hungary in a defensive pact. However, Italy viewed Austria-Hungary as its primary territorial rival (irredentism over Trentino, South Tyrol, Istria, Dalmatia).
When war broke out, Italy declared neutrality, arguing the Alliance was defensive and Austria's aggression against Serbia did not obligate Italy.
Secret negotiations with Britain, France, and Russia promised Italy:
Italy declared war on Austria-Hungary (May 23, 1915) and later Germany (August 1916).
The "Mutilated Victory" (denied Dalmatia/Fiume by Wilson) fueled nationalist resentment, paving the way for Mussolini's rise.
Bottom line: Italy fought WWI as an Associated Power of the Allies (not a formal signatory of the 1907 Triple Entente), driven by territorial ambition rather than treaty loyalty.