Ideogrammic compound (會意／会意): 牛(“cattle”) + 丄. Various explanations exist, some propose 丄 (here unrelated to 上) depicts a penis to represent “male”. Later 丄 came to be written 土. See also the etymology of this character.
An oracle bone graph for this word shows a vertical stick on a horizontal ground, possibly because it had been intended for an obsolete homophone cognate with Proto-Vietic*c-mɔːlʔ(“digging stick”), which alongside "male" may derive from a stem represented in Old Khmercval(“to enter; to penetrate; (of animals) to copulate”), Khmu [script needed] (cmɔɔl, “to plant (rice) with a digging stick”), [script needed] (crmɔɔl, “digging stick”) (ibid.; Ferlus, 1987). Schuessler (2007) further proposes a relationship with 畝 (OC *mɯʔ, “cropland; mu (a Chinese measuring unit for area)”) (ibid.); see there for more.