c. 1400, "a blow, stroke," perhaps originally imitative of the sound. Meaning "light tap with hand" is from c. 1804. Sense of "that which is formed by patting" (as in pat of butter) is 1754, probably from the verb. Pat on the back in the figurative sense "gesture or expression of encouragement, sympathy, etc." is attested by 1804.
1570s, "aptly, suitably, at the right time," perhaps from pat (adj.) in sense of "that which hits the mark," a special use from pat (n.) in the sense of "a hitting" of the mark. The modern adjective meaning "that is exactly to the purpose, suitable for the occasion" is 1630s, from the adverb.
1560s, "to hit, throw;" meaning "to tap or strike lightly" is from 1714; from pat (n.). Related: Patted; patting. The nursery rhyme phrase pat-a-cake is known from 1823. Alternative patty-cake (usually American English) is attested from 1794 (in "Mother Goose's Melody, or Sonnets for the Cradle," Worcester, Mass.).