Interestingly if I remember correctly they have different origins, Maria is a biblical name, while Mario comes from Latin (which can decline Marius to Maria, but that’s a different word)
for people from languages that mark gender with an ending (romance languages for instance), putting the "wrong" ending something like a noun would sound odd or change the meaning