String manufacturers put together string sets based on what they expect that the guitarist will want. They know that some guitarist want light strings, others medium and a few may even want heavy gauge strings.
Within each classification (super light, extra light, light, custom light, medium, heavy etc.) the string makers will choose a gauge for each individual string, that is consistent in terms of the amount of tension needed to tune that string to concert pitch relative to the tension required to tune the other strings in that particular set to concert pitch - assuming standard tuning.
Guitars are also "set up" either in the factory or by a luthier or guitar technician based on the gauge of strings that are most likely to be used - or in the case of a custom set up, the actual gauge that the user specifies. The set up will be completely different for medium strings than for light strings.
One thing that will be different in the set up would be the truss rod tension - which compensates for the string tension - which will be different with different gauge strings. Another thing that might be different would be the width of the slots in the nut and possibly the height of the bridge. Heavier strings will have a wider oscillation pattern but also have a higher tension. These factors can affect how much clearance the strings need from the frets to prevent buzzing.
For a given guitar, set up for a particular gauge string, you could mix and match strings from different manufacturers without damaging the guitar or affecting the playability - as long as the gauge was close to what the guitar was set up for.
The type string and manufacturer of a mis-matched string, even if the gauge is the same as what was in the original set, could affect the tone. And it may feel different than the other strings - especially if you mix coated and non coated strings or flat wound with round wound.
But to answer your question - you could get by with a G string from a different manufacturer and of a different type (don't put a wound acoustic string on an electric guitar). As long as the gauge is not radically different (the other strings are ultra light and your oddball string is from a medium set) you should be able to get by with it with no issues.
As a side note, the G string is the string that breaks most often on sets with a wound G string (includes almost all acoustic sets). That's because the steel core of a wound G string is thinner than even the high E-string. That's why I order extra individual G strings and keep at least one extra G string in my guitar case (along with a full replacement set) so if I break a G string during a live show, I only have to change the one string and I don't have to rob the G string from a full set.
I also sometimes customize my string sets and have my guitar's set up accordingly. I like to use a different combination than what the manufacturers deem as the most common. For example - I have a guitar that is a little weak on the bottom end, so I use heavier bass strings. But again I have the guitar set up specifically for that type of custom string set.
One other note that is on the subject of guitar strings and breaking strings. You should change your guitar strings on a regular basis if you want them to sound good and not break. As you play - pressing the strings against metal frets will wear flat spots on the strings where they contact the frets. Also, the sweat and oils from your fingers will contribute to corrosion of the strings. Even if you don't play the guitar much, the natural oxidation of the metals will cause the strings to weaken and begin to sound dull over time.
There are many excellent answers and recommendations to this question on Music Stack Exchange When and Why to replace guitar strings It is recommended reading for any guitarist.