@applesaucemanny may have a point. G is the fourth string if you count them the way you’re looking at them (closest to furthest away) and it also makes musical sense (it’s the 4th as you go up the tones). If you put a string in that position that says “4” on the label, that will actually be a D, which is pretty weak to start with, and will break easily.
Ds are generally problematic, so even if you’re counting right and put the D on the 4th (counting “normally”, ie going up the guitar), it can easily break. Especially if you accidentally think it should be tuned as a G.
People have mentioned a high (or simply sharp) bridge. Does the string break there? Is it frayed? Or does it just snap?
Some strings also break at the key. When I restring a guitar, I always wind the string a few times around the key first, then put it in the hole. That gives the string some elasticity at that point, and it doesn’t break as easily. I hope you understand what I mean.
The next step is to actually pull the strings (really hard) and then tune them up to their tone (it doesn’t have to be exact, they’ll go out of tune in a second anyway). I pull them again, warm them up, play a few seconds, then pull at different points, then tune again. I repeat this process 3–4 times until the note stabilises. It’s also a way to check the string. If it’s going to snap, at least it will snap now and not during a concert. And it saves you from tuning after every song, which is what most people do with new strings.
I hope some of this helps, but start by checking you’re putting the right strings in the right place. Remember 1 is the really thin E that goes at the bottom, 6 is the thick bronze one at the top.