It's the sort of thing historians argue over a lot, too. I'll probably get this wrong, but will try anyway...
Roughly speaking, Austria held Serbia as a territory.
A Serbian nationalist man (who was actually ethnic Bosnian but never mind that detail) shot the Archduke to try to get Serbia/later Yugoslav area independence from Austro-Hungarian empire.
Austria, outraged, blamed Serbia govt & made loads of demands.
Serbia refused some, Austria declared war.
Russians sided with Serbia and joined in.
Germans felt sympathy with Austria (and saw imperialist possibilities) so declared war too.
Croats sided with Germans (Catholic affinity). Other countries & ethnic groups took sides. It got messy.
England/UK joined in because everyone was afraid of German power. And wanted to protect colonial interests which were being threatened, or wanted to get influence in important areas (like the Ottoman / Turish empire / which was fast collapsing and oil-rich).
It was like a series of dominos. Everyone blamed Germany in the end, but that's a whole 'nother story.