First, regarding the reason the rule in ch. 15 is different from the rule in ch. 20. Critical scholars understand this as resulting from the fact that chapter 15 is part of the "priestly source," while chapter 20 comes from the holiness code. The hypothesis is that these two sources were eventually incorporated in the Bible as we have it today sometime during or shortly after the Babylonian exile.
Professor Christine Hayes of Yale University explains:
"You shall be holy, for I the Lord
your God am holy," ...finds [its] fullest expression in... Leviticus 17 through 26, referred to as the Holiness Code.
There's an important difference between Leviticus 1 through 16 and the
Holiness Code. According to Leviticus 1 through 16, Israel's priests
are designated as holy: a holy class within Israel, singled out,
dedicated to the service of God and demarcated by rules that apply
only to them. Israelites may aspire to holiness, but it’s not assumed.
However, in the Holiness Code, we have texts that come closer to the
idea that Israel itself is holy by virtue of the fact that God has set
Israel apart from the nations to himself, to belong to him, just as he
set apart the seventh day to himself to belong with him.
To be sure, chapter 15 gives rules that apply to the Israelites generally. But if the hypothesis is correct, then the reason for the stricter punishment in chapter 20 would be that it comes from a different (later) source. We see another instance of harsher punishments after the Exile in the laws enacted by the priest Ezra regarding the commandment against intermarriage. In Ezra's time Jews were to divorce their foreign wives (not a requirement in the Torah). Such laws were meant to encourage the people to keep the highest standards of purity.
Unlike in the case of Ezra's reform, the harshness of the penalty need not bother us too much, since it describes an intimate act which would be known only to the man and his wife. There is no known instance of it ever being enforced, and it may have been meant to emphasize that this rule should be taken very seriously.
Conclusion: "How are Leviticus 15:24 and Leviticus 20:18 meant to be understood together?" According to those who hold that Leviticus is composed from more than one source, they are not meant to be "understood together." Chapter 20 was written later, during the period when Israel's priestly leaders were concerned to emphasize the highest possible standards of ritual purity among the people. They thus expressed the rule in stricter terms than the earlier iteration.