1862, short for preparation. Prep school is attested from 1895, short for preparatoryschool. First record of prep in the college slang sense "student or graduate of a preparatory school, student taking a preparatory course of study" is by 1899 (also see preppie).
suffix in pet proper names (such as Johnny, Kitty), first recorded in Scottish c. 1400; according to OED it became frequent in English 15c.-16c. Extension to surnames seems to date from c. 1940. Use with common nouns seems to have begun in Scottish with laddie (1546) and become popular in English due to Burns' poems, but the same formation appears to be represented much earlier in baby and puppy.