The Austria-Hungary empire was spreading its influence over the region and controlled a part of the Balkans. The local population which was Slavic disliked this because they feared that Austria-Hungary might occupy and attack them in such a short period of time after they managed to become independent from the Ottomans. When Franz Ferdinand was assassinated by Gavrilo Princip who wanted to free Bosnia and Herzegovina of Austrian rule, the Empire issued the July ultimatum which was rejected by the Serbian government. This rejection marked the beginning of world war 1.
The rise of nationalism on the Balkans was a result of Austrian and Ottoman rule over the region. The local Slavic population wanted to become independent and fought wars against the Ottomans and managed to gain its independence and self-determination after 500 years of Ottoman rule. Austria-Hungary disliked this and wanted to exploit the situation for its own benefit since Serbia was a new country with numerous problems
Austria-Hungary became like this due to the Napoleonic wars. During the wars its role was sometimes helpful to Napoleon's cause while most of the time it was a part of the coalition forces against him. The war weakened the Austrian empire and they started losing their respect that they had so they knew that they needed to reassert their dominance in Europe. Austrians, just like Germans, needed more territory and colonies and similar things in order to compete with other great European forces.