Spanish words are either masculine (-o) or feminine (-a)
The case for problema is an exception that does not follow the rules. It is a masculine word that ends in -a. Something about the transition from a Greek word to Spanish made it not follow the rules. (And I was told English was the only language that did not follow its rules...lol)