It’s always possible that Westerosi law differs from OTL Western European law, but yes, it would be unlikely that an annulment (as opposed to a divorce) would be allowed in a case where there are children, especially a male child.
In the case of Margaery, the plot only makes sense if Cersei’s children can be disinherited due to revelations of incest and adultery. As for “until such time,” I think it was planned to be very quick in succession: Robert gets infatuated, wants to get rid of Cersei, Renly steps forward with the awful truth, Robert is enraged and humiliated, hey presto here’s the lovely Margaery in his bed to console his ego and produce legitimate male heirs, what a lovely wedding/war…