This is a gross oversimplification. I'll tackle the immediate causes of the war, but this post from the FAQ has a wonderful background on it, as do some other posts in the FAQ.
Archduke Ferdinand was assassinated by a Serbian group called "The Black Hand". While many of them were army officers, they did not constitute the full government nor a majority of it. The government on the whole did not sanction their actions.
Even if the government sanctioned their actions, there is a greater need than that for jus ad bellum (right to war), if the assassinating faction provides for appropriate reparations and proves they were not actually sanctioning the actions. In fact, this is reinforced by the July Ultimatum that Austria-Hungary sent to Serbia. The text of that can be found below, or at the link below that:
to suppress every publication which shall incite to hatred and contempt of the Monarchy, and the general tendency of which shall be directed against the territorial integrity of the latter;
to proceed at once to the dissolution of the Narodna Odbrana to confiscate all of its means of propaganda, and in the same manner to proceed against the other unions and associations in Serbia which occupy themselves with propaganda against Austria-Hungary; the Royal Government will take such measures as are necessary to make sure that the dissolved associations may not continue their activities under other names or in other forms;
to eliminate without delay from public instruction in Serbia, everything, whether connected with the teaching corps or with the methods of teaching, that serves or may serve to nourish the propaganda against Austria-Hungary;
to remove from the military and administrative service in general all officers and officials who have been guilty of carrying on the propaganda against Austria-Hungary, whose names the Imperial and Royal Government reserves the right to make known to the Royal Government when communicating the material evidence now in its possession;
to agree to the cooperation in Serbia of the organs of the Imperial and Royal Government in the suppression of the subversive movement directed against the integrity of the Monarchy;
to institute a judicial inquiry against every participant in the conspiracy of the twenty-eighth of June who may be found in Serbian territory; the organs of the Imperial and Royal Government delegated for this purpose will take part in the proceedings held for this purpose;
to undertake with all haste the arrest of Major Voislav Tankosic and of one Milan Ciganovitch, a Serbian official, who have been compromised by the results of the inquiry;
by efficient measures to prevent the participation of Serbian authorities in the smuggling of weapons and explosives across the frontier; to dismiss from the service and to punish severely those members of the Frontier Service at Schabats and Losnitza who assisted the authors of the crime of Sarajevo to cross the frontier;
to make explanations to the Imperial and Royal Government concerning the unjustifiable utterances of high Serbian functionaries in Serbia and abroad, who, without regard for their official position, have not hesitated to express themselves in a manner hostile toward Austria-Hungary since the assassination of the twenty-eighth of June;
to inform the Imperial and Royal Government without delay of the execution of the measures comprised in the foregoing points.
Link: http://wwi.lib.byu.edu/index.php/The_Austro-Hungarian_Ultimatum_to_Serbia_(English_translation)
The response can be found at the link below:
Let me sum it up for you: basically, Serbia said "You can do whatever you want except send your police to investigate with us". They clearly were taking some pretty big concessions on this one: if they'd intended the assassination, they were either unprepared for the repercussions (unlikely) or were a lot dumber than everyone took them for.
Austria-Hungary still declared war, as detailed here:
The Royal Serbian Government not having answered in a satisfactory manner the note of July 23, 1914, presented by the Austro-Hungarian Minister at Belgrade, the Imperial and Royal Government are themselves compelled to see to the safeguarding of their rights and interests, and, with this object, to have recourse to force of arms. Austria-Hungary consequently considers herself henceforward in state of war with Serbia.
Following this, everyone mobilized. Germany had promised to support Austria-Hungary, by means of the Triple Alliance:
They engage henceforward, in all cases of common participation in a war, to conclude neither armistice, nor peace, nor treaty, except by common agreement among themselves.
Source: http://wwi.lib.byu.edu/index.php/Amended_Version_of_The_Triple_Alliance
On the other end, Russia began a partial mobilization (likely to protect Serbian interests, which they had connections with), then Germany fully mobilized, then Russia fully mobilized. Then Germany declared war on Russia to pre-empt what they felt was an imminent threat, and then the Triple Entente came into play, and voila, we have a war.