number, wharf, agate, yard (91.44 cm)
碼 centers on a unit of measurement or a marker: a yard (length), a number, or a wharf (a measured landing place). The agate sense is a separate, rare meaning for a patterned stone.
碼 combines 石 (stone) with 馬 (horse), likely as a phono-semantic compound where 馬 suggests the sound and 石 relates to stone weights or markers used for measurement.
A stone 石 weight shaped like a horse 馬 is used to measure a yard of cloth at the wharf, with numbers stamped on it.
For バ, imagine a baa-ing sheep standing on the stone wharf, measuring a yard of wool: baa -> バ.