Found out the problem. The UIDs were being returned correctly.
My problem was: I was using a function to manually fetch an email based on its UID. So in the case of the inbox, I obtained the UIDs, then used this function to obtain each mail in specific. With each label, the same.
However, each specific email was being returned for the inbox, but in the case of a label, I wasn't able to fetch each mail. I therefore assumed I wasn't passing the correct UID to the function.
My mistake was not related. Inside the function to fetch a specific mail, instead of fetching it from the label in question, I was always fetching from the inbox.
So in this case, for the inbox I would obtain a list of UIDs, then use this function to successfully obtain each mail in specific, but in the case of a specific GMail label I would obtain the list of UIDs, then fail to fetch each specific mail because I was performing select on the inbox.
Changed the select from the inbox to the specific label inside the function that fetches each specific mail, and now works perfect.