A really basic idea of compression would be if you had a file with the string “foobar” repeated 10x, the it could be compressed to “foobar*10” instead of writing out foobar 10x.
Obviously this is a trivialised example, but thinking of compression like that, it should become more readily apparent why compressed files in general can be deduplicated.
Perhaps you were thinking of encryption? which doesn’t deduplicate well.
As an aside, you might find this topic interesting (although it is for compressed tar, not rar):