Clicking on icons in the global queue does not always dequeue the item clicked, but rather dequeues the first item in queue for the building
For Example, if one queues a Teutonic Knight unit then a trebuchet (in the same castle). Clicking the trebuchet would dequeue the Teutonic Knight.
I hope this would be fixed in a later patch.