The display manager, as the name says, manages a "display" (or sometimes several), in the world of X that is a monitor/keyboard/mouse combination somewhere. Decades ago there were multiple such "displays" attached to a single machine; today it is rare to see more than one (and multi-seat gets handled a bit differently).
The display manager can start the X server for that display, will restart it if it fails, and also (usually) presents a login screen to the user. So in that sense it is a "login manager" (though I've never heard the term "login manager" used).
So the display manager is started first.
xdm is one of the oldest display managers, both Gnome and KDE have their own display manager (
kdm), and there are others like e.g.
The X server is a program that allows X clients (application programs) to put content on a display. Clients talk to the server locally or (rarely today) over the network using the X protocol.
The X server is started by the display manager, but you can also start the X server manually (often with a program called
startx) if you don't use a display manager.
There are no variations for the X server (simplifying a bit). However, modern distros increasingly use Wayland as an alternative to the X server.
A Window Manager (WM) is a special X client with privileges that allow it to control the windows of other applications to some degree. It will paint decorations (like title bars) around those windows, it will implement key bindings to manipulate windows, it will deal with requests to iconify, minimize, maximize, or otherwise change the size of the windows, etc.
There are many different window managers, which one to use depends on your taste. The window manager is usually started by the display manager when it executes (default or customized) scripts during the login of a specific user. So each user can have a different window manager.
On modern distros, you never have to deal with all of that yourself (unless you want to): You can just pick a Gnome or KDE desktop (or other variants), and everything will be installed and configured for you.
Or you can mix and match, and install those parts you want of you don't want to use any of the "big" desktops (for example, I use
fvwm). But then you need to understand the parts a lot better.