Shrink in this case is an abbreviation of headshrinker, which was a slang term for a psychiatrist (or mental-health professional in general), from around the late 1940s or early 1950s. I guess it came about because patients felt like the pressure of treatment made it feel like their heads were being shrunk. Some also think it refers to the deflation of the patients’ egos.
It’s telling that shrink is sometimes used to refer to both psychiatrists and psychologists. People often get confused between the two, because they both deal with the mind. Psychology is a broader field, dealing with human emotions and behaviour in general, with psychologists tending to specialise in certain fields. Psychology, appropriately enough, means knowledge of the soul, derived from the Greek psyche (soul) and -logia (study of).
A psychiatrist, on the other hand, specifically treats mental illness, and the word’s etymology is also appropriate. It means healer of the soul: psyche + iatreia (healing). An appropriate title for what must be an incredibly challenging job.