It passes events, from button to code (in binary) which executes code in machine code such as (0xE9 is jmp) and 0xC3 is return and so on.
If you studied OOP's Object Orientated programming you will know Button is a object it is part of the Window but imagine it is a child window in side the window, and when the mouse performs a up down motion, the windows kernel drivers responsible for interpreting IO hardware will pass the information such as coordinates the Up-Down motion took place and pass it on to User-Mode through varitety of means such as passing it via Zw* function and then passes through system call stub KiFastSystemCall and X86SwitchTo64BitMode which then passes through NT function finally through a calling function which will finally perform a action.
I am not too sure but I guess it passes through undocumented functions like NtGdi* (for graphics), there is no way one can know how exactly they function as Windows is a closed source and quite a few people only know the true full-level of functionality of Windows NT kernel, and Microsoft as you know are too protective over their softwares and will not give away data\information about their technical details regarding products.
This was all top of my head and do not rely on the information provided as this could have quite a few error. Although I am sure more advanced Winapi users can provide details.
Does it check the co-ordinates of mouse and the buttons ?
Yes. (Assuming "it" is Windows.)
Windows searches for the window highest in the z-order (i.e. the one in front) which contains the mouse position and sends it the mouse messages (WM_LBUTTONDOWN, WM_MOUSEMOVE, etc.)
Controls like buttons handle the mouse messages (in their WndProc) and then send WM_COMMAND messages or WM_NOTIFY messages to their parent. For example, when a button is clicked on it will send a WM_COMMAND message to its parent window which includes its ID, its HWND, and the notification code BN_CLICKED.
Keyboard messages (WM_KEYDOWN, WM_CHAR, ...) are sent to the window which has the focus, which might be different to the one where the mouse is currently located.
PS There are exceptions. For instance, you can make a window transparent to mouse clicks. When this is done, the window is drawn as normal but it is not sent mouse messages. They are sent to the windows lower down.