Typically, creatures from types like Undead or Construct have no intelligence scores. However, there are examples of both that have intelligence scores (Say, a Vampire and an enhanced Clockwork Servant). Since these creatures are no longer 'mindless', do they retain their immunity to mind-affecting effects?
It depends on the details of the case, but in both of your examples, yes, they do stay immune. Both Undead and Constructs have "immune to mind-affecting" as a creature-type trait, listed independently of any tendency for many creatures of that type to be mindless. Thus, even a creature of these types who is not mindless still has this immunity. However, if the creature does not have any such Intelligence-independent trait granting them immunity, and is only immune via the
clause in the magic rules (for example, most Oozes), then no, they would not retain their immunity if granted an Intelligence score. (Note that, in the Ooze's case, at least, this exception is explicitly called out in their version of the Mindless creature-type trait.)
Presumably, the minds of undead and intelligent constructs simply function, mechanistically, in ways sufficiently different from the functional mechanisms of organic minds, to not be manipulable by the same effects.
There are effects of nonabilities in various scores, these are laid out clearly. Technically, due to the wording of the three applicable sources, some undead and constructs actually have immunity to mind-affecting effects twice. This means that if they lose one source, the other remains.
So the only way to affect a mindless undead with a mind-affecting spell is to make it not-undead and give it an int. Baleful Polymorphing it into a bunny and casting Awaken Animal on it would work, although, i'm not sure what you'd hope to gain at that stage.