As per your requirement, Just create two categories like cat1 and cat2. After that, you can assign categories from the Post A and Post B.
Then WordPress creates the default URL Like this:
Post A: example.com/cat1/post-a
Post B: example.com/cat2/post-b