"small, slightly sweetened roll or biscuit," late 14c., origin obscure and much-disputed; perhaps [Skeat] from Old French buignete "a fritter," originally "a boil, a swelling," diminutive of buigne "swelling from a blow, bump on the head," from a Germanic source (compare Middle High German bunge "clod, lump"), or from Gaulish *bunia (compare Gaelic bonnach; see bannock). Spanish buñelo "a fritter" apparently is from the same source. Of hair coiled at the back of the head, first attested 1894. To have a bun in the oven "be pregnant" is from 1951.
The modern popular use of buns in the sense of "male buttocks" is from 1960s, perhaps from a perceived similarity; but bun also meant "tail of a hare" (1530s) in Scottish and northern England dialect and was transferred to human beings (and conveniently rhymed with nun in ribald ballads). This may be an entirely different word; OED points to Gaelic bun "stump, root."