So how do native speakers figure it out?
Maybe answers like "memorise it" were/are unsatisfying to you, because it is hard to imagine German toddlers to sit at a desk memorise noun's genders by using flash cards or similar.
And of course, it is not happening that way.
The toddler hears adults using certain articles or pronouns in the context of a certain noun.
Der Ball ist rund.
Der Ball ist rot.
Wo ist der Ball?
The repetition (over several months or even years) leads to memorising this particular pattern. This is the same for the altered articles in the different cases. A toddler learns that it is den Ball if the ball is object to geben:
Gib mir den Ball!
... although the toddler does not know anything about nouns, genders, cases or objects as linguistic concepts, (these concepts are taught later at school). The toddler just memorises the patterns, without using flashcards or the like.
The human brain is awesome, right?
How can I determine a words gender in German when speaking or reading?
Well, as the others wrote: memorise is the answer here.
The challenge is, to find the best way for you to memorise.
Maybe flash cards are cool, maybe you prefer the "German kids way" and interact with a native German speaking partner - most likely a combination of several methods will do the trick. Make sure, it does not get boring - brains do not like boring ;)