On June 28th, 1914, Archduke Franz Ferdinand was murdered by the Black Hand, a Serbian secret society. Austria-Hungary was furious with the murder of their archduke, and declared war or Serbia that same day.
With many treaties bonding other countries together in a time of need like war, Germany joined with Austria-Hungary and Russia joined with Serbia. France was then attacked by Germany for joining with Russia and the British came in to aid the French. Japan, holding a treaty with Britain, declared war on Germany. When Germany threatened to cut off the United States' commercial shipping, they declared war on Germany.
The Triple Entente consisted of Britain, Russia, and France. In 1890, Germany decided against renewing its alliance with Russia. While this was occurring, Germany was also being hostile towards France which caused the French to want an ally. This was understood by both sides, and by 1894, there was a dual alliance between the two. Britain, in 1898, was looking for an alliance but had issues with both France and Russia. With the new elected leader in France, the British gained their trust. Soon after, The Russians and the British came up with an agreement between them and formed the Triple Entente in 1907.
The Triple Alliance consisted of Germany, Austria-Hungary, and Italy. These allies joined together in 1882, so that they could work together instead of competing for land or power. This agreement said that either country could take over land and the other had to be okay with that.