This is a doujin from back before Rebellion came out...you should probably imagine that it happens in a 'Madoka manages to materialize as a goddess and live as Homura's wife' universe. The sequences aren't random at all, they're a bunch of moments highlighting the theme of the story, (namely 'the things that have happened, can't be erased'). The reversal in Madoka's position about redoing things is an illustration of the shift in perspective Madoka gained after becoming a goddess; the point of the sex scene was showing Madoka's despair in an earlier timeline about her relationship with Homura being erased back when Homure was stuck in her timeloops.