Italy was in alliance with Austria-Hungary and Germany. But Italy reneges on the agreement to support the two. Because the agreement stated that in case of an attack on their country the others would help them. But it was Austria-Hungary and Germany that were invading Serbia. They started the attacks. So Italy claimed that they weren’t bound to help. But because the Ottoman empire had enmity with Russia, the Ottoman empire reached in support of the Austro-Hungarian empire.
The United Kingdom gets involved in this too. Because Russia, France, and Britain had an alliance treaty called the Triple Entente. This was how the Great war ensued. In which all these countries were at war with each other.
Later, countries like the USA and Japan join this war in support of Britain and France. And obviously, the countries that were under British rule, like India, gets involved in this war. Because the British needed soldiers. And the easiest option was to use the people of the countries Britain had colonised as soldiers.
Many Indians went to participate in World War I on behalf of Britain. This was how World War I Began.