Piecing this together, it appears that OP is speaking about two experiences transiting Mexico. Thus, Global Entry would have nothing to do with it.
Given that this happened twice, it is entirely possible that OP is on some form of watch list for Mexico and that he can expect this treatment when entering (or transiting) Mexico going forward. Could be that there is a name match to some "bad guy," could be an outright error, or could be that there is a specific reason. But, bottom line is that the local Consulate is not going to obtain this information for OP.
Agreed that this is a hassle and that the conditions of confinement are unsafe. Best to avoid Mexico for the time being, when possible.
Passport data and the like doesn't matter. Mexico, of course, has that for all passengers whether they are pulled into secondary or not.