Both nouns are masculine, but here genders do not have to match. A woman and a child also can have a tomato.
Both nouns are exceptions in different ways.
Mężczyzna is in nominative case- it is "dictionary form" and most nouns ending with -a are feminine, but there are some nouns that end with -a, and are masculine. (most obvious are "mężczyzna"- man and "tata"-dad)
Those nouns have case endings like feminine ones, but adjectives, pronouns and verbs need to be masculine.
Pomidor is a nominative case of tomato. It is a masculine noun.
You need accusative case alter "mam" and pomidor has accusative=genitive pomidora.
This accusative=genitive thing happens when masculine noun is "animate"- describes an animal or a person, but certain nouns behave that way even though they are not animals, - mostly food and technology related words.