It doesn't matter what his salary cap hit was in the middle of 2023. He was set to become a free agent and got paid. If the Rams deal for Burns he's going to get a new deal too. And it's doubtful it will have a $24 million cap number the first couple of seasons at least.
Sweat is also two years older than Burns.
He may have had a better season last year, but they were in the same draft class and Burns has better career numbers. And this with Sweat playing on a DLine full of other 1st round talents for opposing offenses to consider before he was dealt.
And again, last year Burns situation simply wasn't conducive to him putting up similar numbers. Teams weren't threatened by the Panthers offense. If I'm not mistaken their defense had the fewest passing attempts against them in the entire NFL.