You'll find a more detailed discussion of the XML ID reference mechanism in Chapter 7, Module Data. For now, just keep in mind that you can set references this way and—very important—that order matters. If the preceding tags were inverted, the addon containing this XML code wouldn't install, because the menuitem would refer to an unknown action.
The ir.actions.act_window action type is the most common one, but a menu can refer to any type of action. Technically, it is just the same if you link to a client action, a server action, or any other model defined in the ir.actions.* namespace. It just differs in what the backend makes out of the action.
If you need just a tiny bit more flexibility in the concrete action to be called, look into server actions that return a window action in turn. If you need complete flexibility on what you present, look into client actions (ir.actions.client), which allow you to have a completely custom user interface. However, only do so as the last resort as you lose a lot of Odoo's convenient helpers when using them.