The premise is incorrect. Austria-Hungary and Serbia were opposing belligerents in World War I:
The war began when Austria-Hungary declared war on Serbia (July 28, 1914) after the assassination of Archduke Franz Ferdinand. No country "came to help both"—they fought on opposite sides.