If the I-485 is approved, the I-864 remains valid and enforceable until the sponsored immigrant accumulates 40 credits for Social Security or is no longer a permanent resident (whether that happens by deportation, departure, death, or becoming a US citizen).
Enforcement would normally take the form of the government pursuing the sponsor (and joint sponsors, if any) to recover the welfare-related funds that were taken by the immigrant. Also, if the immigrant has income below 125% of the poverty line, the immigrant can sue the sponsor(s) to make up the difference to bring them up to the 125% level. However, I have never heard or read of a successful lawsuit like that, except where it involved one ex-spouse suing the other after divorce.
If after I-485 it is found to be a sham marriage, the immigrant would get deported and the I-864 would be terminated. The citizen or permanent resident who married the immigrant spouse could also be fined or imprison for fraud, if they were found to be deliberately participating in the scam (often the fraud is one-sided; the USC or LPR spouse is genuinely in love, but the immigrant spouse married them only for the GC).
Note that there is a difference between having insufficient evidence of a bona fide marriage, and finding that it is a sham marriage. Most denials are for the first reason, and those couples often have success if they reapply or reopen the case and provide more evidence.