Think of X as a standardized system for creating and displaying graphical interfaces. KDE and Gnome are desktop systems that rely on the X-windows systems.
Metaphor (sad attempt): If linux is the foundation of a home, then X-windows is the framing and so forth that give you walls to paint and floors to cover with carpet and hard-wood so it is comfy which would be the desktops.
X-windows doesn't only exist on linux/unix. I used to use an X-windows server (there's more depth on that than I will go into now, post again if you are interested) in MS Windows, and the Mac OSX has an X-windows server.