What’s happening here is that these people were here on tourist visas or completely illegally. Then at some point they married a U.S. citizen and filed a PERM application. But that filing doesn’t protect them from deportation for their original illegal status.
There's no PERM process in family based adjustment of status. You're confusing FB AOS with EB AOS.
Subsection (d) allows the attorney general to grant an AOS notwithstanding subsection (c) where an immigrant enters j to a bona fide marriage during proceedings regarding their immigration status. But under subsection (a) the AOS is entirely at the “discretion” of the Attorney General.
Indeed, section 1255 doesn’t grant anyone legal status. It contains various provisions where an AOS must be denied. Then, it allows but does not require the Attorney General to grant an AOS under other circumstances.