Great Britain, Germany, Austria-Hungary and Russia were the Great Powers(I think), but I feel like they could have avoided WW1 with a pact or a treaty but I'm unsure why they couldn't.
Because all the grear powers wanted war. They thought war was inevatable to sort out rivalleries. Blaming the war just on those who lost the war, Germany, Austria-Hungary and the Ottoman Empire was toxic and wrong.
I think your viewing on the situation is a bit astray. If signing a treaty could've solved all the problems of early 20th century Europe, then there wouldn't of had to be a continental conflict. Germany wanted to exploit any international conflict it could for its own investment, however, Russia was a huge roadblock in the way of achieving this. By "this" I mean European hegemony. This is a pretty simple way of looking at it I believe if your a bit confused on how everything panned out, especially considering the amount of things that lead up to the outbreak of war