Basically, Google Docs writes several representations of the data to the pasteboard (that's what it is called in OS X). Then whatever app you paste into reads an appropriate representation of the data from the pasteboard.
From the Pasteboard Programming Guide:
Pasteboard operations are often carried out between two different applications. Neither application has knowledge about the other and the kinds of data each can handle. To maximize the potential for sharing, a pasteboard can hold multiple representations of the same pasteboard item. [...] An item that is added to a pasteboard specifies what representations it is able to provide.
A pasteboard reader must find the data type that best suits its capabilities (if any). Typically, this means selecting the richest type available. [...] a rich text editor might provide RTFD, RTF, and
NSString representations of copied data. An application that supports rich text but without images should retrieve the RTF representation; an application that only supports plain text should retrieve the
NSString object, whereas an image-editing application might not be able to use the text at all.
The clipboard in Windows works basically the same way.