Turns out caterpillars don't wrap themselves in silk to become a cocoon like I'd been led to believe; though some do after becoming a chrysalis and that's when it's called a cocoon.
A caterpillar's chrysalis, which is basically just hard skin, develops under a caterpillar's outer skin. It sheds its skin multiple times as it grows until the chrysalis is developed enough for the caterpillar to pupate. When the time comes, it finds a spot, usually a surface to anchor itself to, and then begins the process of shedding to become a chrysalis.
I found this out about 2 weeks ago but was too lazy to post about it sooner.
Caterpie's evolution in Pokemon S1 Episode 3 is LIES.