Best practices: Position of cancel button in modals

I am currently working on modals for our software and I have been placing the 'Cancel' button always on the extreme left (Version A in picture). However while documenting myself more on modals, I discovered that most websites seem to put the buttom closer to the primary button found on the right (Version B in picture). Is there a specific usability reason why the second option is more adopted? I am unsure whether I should keep Version A or not. Thank you to anyone who will answer!

modal options