Yes, it stems from Latin. See Latin's case declension tables [0]
In Spanish and Portugese, -a is a feminine suffix and -o is masculine; that's where we get Patricio vs Patricia.
There are very few female names that end with -o and very few male names that end with -a in Spanish.
Another example is -ine in Joseph/Josephine. -ine/-ino/-in is a feminizing suffix in German and a diminutive in Spanish and French, that's why it's a femenine suffix in names. In English we have hero vs heroine.
[0]: https://dcc.dickinson.edu/grammar/latin/case-endings-five-de...
There are a few common Italian male names end in -a, though.
Andrea, Luca, Nicola are the most common.