c. 1400, "a blow, stroke," perhaps originally imitative of the sound of patting. 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 attested by 1804.

"aptly, suitably, at the right time," 1570s, perhaps from pat (adj.) in sense of "that which hits the mark," a special use from pat (n.) in sense of "a hitting" of the mark. The modern adjective is 1630s, from the adverb.