If you are in a state of mortal sin, you have chosen to break spiritual communion with Christ. It would then be inconsistent and hypocritical to receive Holy Communion at Mass because you are not in a state of grace - i.e., you are not in actual communion with Christ.
An analogy is okay, but it limps because it is not a complete explanation. But one analogy would be a husband who cheats on his wife and breaks that bond they share. His wife knows and is upset, but instead of seeking reconciliation with his wife, he simply demands conjugal relations. That physical union means nothing because the emotional union has not been reconciled. In fact, the husband is taking the wife for granted and that further humiliates her.
In this analogy, the husband represents the unrepentant sinner and Christ the humiliated wife. Christ is there for us to receive, but that union must be undergirded by a living spiritual union. If we are not in a state of Grace, then we are not spiritually united with Christ, and the reception of actual Holy Communion at Mass does not force reconciliation with Christ - in fact, it takes Christ for granted and adds the sin of sacrilege because we desecrate the sacrament. We must go to Confession first and receive forgiveness from the Church before we receive Christ in the Blessed Sacrament from the Church.